Skip to content

Commit

Permalink
util: test the UTF-8 support of the current LC_CTYPE
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Sep 22, 2024
1 parent c5caedf commit 537c650
Show file tree
Hide file tree
Showing 5 changed files with 343 additions and 22 deletions.
24 changes: 13 additions & 11 deletions ble.pp
Original file line number Diff line number Diff line change
Expand Up @@ -1475,15 +1475,18 @@ function ble/base/is-msys1 {
[[ $OSTYPE == msys && ! $cr ]]
}

_ble_base_is_wsl_status=
function ble/base/is-wsl {
[[ $_ble_base_is_wsl_status ]] && return "$_ble_base_is_wsl_status"
_ble_base_is_wsl_status=1
[[ -d /usr/lib/wsl/lib && -r /proc/version ]] || return 1
local kernel_version
ble/bash/read kernel_version < /proc/version || return 1
[[ $kernel_version == *-microsoft-* ]] || return 1
_ble_base_is_wsl_status=0
if [[ -d /usr/lib/wsl/lib && -r /proc/version ]] &&
ble/bash/read kernel_version < /proc/version &&
[[ $kernel_version == *-microsoft-* ]]
then
function ble/base/is-wsl { return 0; }
return 0
else
function ble/base/is-wsl { return 1; }
return 1
fi
}

function ble/util/mkd {
Expand Down Expand Up @@ -1734,11 +1737,9 @@ function ble/base/initialize-runtime-directory/.xdg {
[[ -d $runtime_dir && -O $runtime_dir ]] || return 1
fi

# Note: Some versions of WSL around 2023-09 seem to have an issue in the
# Note: Some versions of WSL around 2023-09 seem to have an issue with the
# permission of /run/user/*, so we avoid to use them in WSL.
[[ $runtime_dir == /run/user/* ]] &&
ble/base/is-wsl &&
return 1
[[ $runtime_dir == /run/user/* ]] && ble/base/is-wsl && return 1

if ! [[ -r $runtime_dir && -w $runtime_dir && -x $runtime_dir ]]; then
[[ $runtime_dir == "$XDG_RUNTIME_DIR" ]] &&
Expand Down Expand Up @@ -2612,6 +2613,7 @@ function ble-attach {
# terminal state and send requests. We then calculate the first prompt,
# which takes about 50ms, while waiting for the responses from the
# terminal.
ble/util/notify-broken-locale
ble/term/initialize # 0.4ms
ble/term/attach noflush # 2.5ms (起動時のずれ防止の為 stty -echo は早期に)
ble/canvas/attach # 1.8ms (requests for char_width_mode=auto)
Expand Down
3 changes: 3 additions & 0 deletions docs/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@
- util (`ble/util/buffer.flush`): use <kbd>DECSET(2026)</kbd> in terminals with the support `#D2226` c3df08be
- main: refactor initialization sequence `#D2231` cc9d7f39
- util (`ble/util/is-stdin-ready`): check `$_ble_util_fd_tui_stdin` by default `#D2254` 29c00fd8
- decode (`ble-decode-key/bind`): reference the argument to check the widget name (contributed by musou1500) `#D2279` xxxxxxxx

<!---------------------------------------------------------------------------->
# ble-0.4.0-devel3
Expand Down Expand Up @@ -705,6 +706,7 @@
- util (`ble/string#split`): optimize `#D1826` 7bb10a7
- global: avoid passing arbitrary strings through `awk -v var=value` `#D1827` 82232de
- edit: properly set `LINENO` for `PS1`, `PROMPT_COMMAND`, and `DEBUG` `#D1830` 4d24f84
- complete: generate command names in background with slow WSL2 `PATH`s (contributed by musou1500) `#D2280` xxxxxxxx

## Compatibility

Expand Down Expand Up @@ -783,6 +785,7 @@
- syntax: suppress brace expansions in designated array initialization in Bash 5.3 `#D1989` 1e7b884
- progcomp: work around slow `nix` completion `#D1997` 2c1aacf
- complete: suppress error messages from `_adb` (reported by mozirilla213) `#D2005` f2aa32b0
- util: test the UTF-8 support of the current `LC_CTYPE` `#D2281` xxxxxxx

## Test

Expand Down
4 changes: 4 additions & 0 deletions lib/core-complete.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2563,6 +2563,10 @@ function ble/complete/source:command/.print-command {
shopt -q no_empty_cmd_completion && return 0
slow_compgen=1
elif [[ :$PATH: == *:/mnt/*:* ]] && ble/base/is-wsl; then
# Note #D2280: Since the upstream WSL2 doesn't seem to be going to fix
# the slow filesystem issue with /mnt/*, we decided to add a workaround.
# https://github.com/akinomyoga/ble.sh/issues/96
# https://github.com/akinomyoga/ble.sh/pull/504
slow_compgen=1
elif [[ $OSTYPE == cygwin* ]]; then
case $COMPV in
Expand Down
Loading

0 comments on commit 537c650

Please sign in to comment.