Skip to content

Commit

Permalink
main: update the startup message for debug versions of Bash
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Jun 11, 2024
1 parent 48c7bbe commit afb2907
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 14 deletions.
93 changes: 84 additions & 9 deletions ble.pp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ function ble/util/print { printf '%s\n' "$1"; }
' --keep-rlvars' \
' Do not change readline settings for ble.sh' \
'' \
' --bash-debug-version=TYPE' \
' This controls the warning mesage for the debug version of Bash. When' \
' "full" is specified to TYPE, ble.sh prints the full message to the terminal' \
' when it is loaded in a debug version of Bash. This is the default. When' \
' "short" is specified, a short version of the message is printed. When' \
' "once" is specified, the full message is printed only once for a specific' \
' version of debug Bash. When "ignore" is specified, the message is not' \
' printed even when ble.sh is loaded in a debug version of Bash.' \
'' \
' -o BLEOPT=VALUE' \
' Set a value for the specified bleopt option.' \
' --debug-bash-output' \
Expand Down Expand Up @@ -894,6 +903,24 @@ function ble/base/read-blesh-arguments {
_ble_base_arguments_rcfile=/dev/null ;;
(--keep-rlvars)
opts=$opts:keep-rlvars ;;
(--bash-debug-version=*|--bash-debug-version)
local value=
if [[ $arg == *=* ]]; then
value=${arg#*=}
elif (($#)); then
value=$1; shift
else
opts=$opts:E
ble/util/print "ble.sh ($arg): an option argument is missing." >&2
continue
fi
case $value in
(full|short|once|ignore)
opts=$opts:bash-debug-version=$value ;;
(*)
opts=$opts:E
ble/util/print "ble.sh ($arg): unrecognized value '$value'." >&2
esac ;;
(--debug-bash-output)
bleopt_internal_suppress_bash_output= ;;
(--test | --update | --clear-cache | --lib | --install)
Expand Down Expand Up @@ -968,15 +995,6 @@ function ble/base/read-blesh-arguments {
#------------------------------------------------------------------------------
# Initialize version information

# DEBUG version の Bash では遅いという通知
case ${BASH_VERSINFO[4]} in
(alp*|bet*|dev*|rc*|releng*|maint*)
ble/util/print-lines \
"ble.sh may become very slow because this is a debug version of Bash" \
" (version '$BASH_VERSION', release status: '${BASH_VERSINFO[4]}')." \
" We recommend using ble.sh with a release version of Bash." >&2 ;;
esac

_ble_bash=$((BASH_VERSINFO[0]*10000+BASH_VERSINFO[1]*100+BASH_VERSINFO[2]))
_ble_bash_loaded_in_function=0
local _ble_local_test 2>/dev/null && _ble_bash_loaded_in_function=1
Expand Down Expand Up @@ -2190,6 +2208,63 @@ function ble/base/initialize-session {
}
ble/base/initialize-session

# DEBUG version の Bash では遅いという通知
function ble/base/check-bash-debug-version {
case ${BASH_VERSINFO[4]} in
(alp*|bet*|dev*|rc*|releng*|maint*) ;;
(*) return 0 ;;
esac

local type=check ret
ble/opts#extract-last-optarg "$_ble_base_arguments_opts" bash-debug-version check && type=$ret
[[ $type == ignore ]] && return 0

local file=$_ble_base_cache/base.bash-debug-version-checked.txt
local -a checked=()
[[ ! -d $file && -r $file && -s $file ]] && ble/util/mapfile checked < "$file"
if ble/array#index checked "$BASH_VERSION"; then
[[ $type == once ]] && return 0
else
ble/util/print "$BASH_VERSION" >> "$file"
fi

local sgr0=$_ble_term_sgr0
local sgr1=${_ble_term_setaf[4]}
local sgr2=${_ble_term_setaf[6]}
local sgr3=${_ble_term_setaf[2]}
local sgrC=${_ble_term_setaf[8]}
local bold=$_ble_term_bold
if [[ $type == short ]]; then
ble/util/print-lines \
"Note: ble.sh can be very slow in a debug version of Bash: $sgr3$BASH_VERSION$sgr0"
else
ble/util/print-lines \
"$bold# ble.sh with debug version of Bash$sgr0" \
'' \
'ble.sh may become very slow because this is a debug version of Bash (version' \
"\`$sgr3$BASH_VERSION$sgr0', release status: \`$sgr3${BASH_VERSINFO[4]}$sgr0'). We recommend using" \
'ble.sh with a release version of Bash. If you want to use ble.sh with a' \
'non-release version of Bash, it is highly recommended to build Bash with the' \
"configure option \`$sgr2--with-bash-malloc=no$sgr0' for practical performance:" \
'' \
" $sgr1./configure $bold--with-bash-malloc=no$sgr0" \
'' \
'To suppress this startup warning message, please specify the option' \
"\`$sgr2--bash-debug-version=short$sgr0' or \`${sgr2}once$sgr0' or \`${sgr2}ignore$sgr0' to \`ble.sh':" \
'' \
" ${sgrC}# Show a short version of the message$sgr0" \
" ${sgr1}source /path/to/ble.sh $bold--bash-debug-version=short$sgr0" \
'' \
" ${sgrC}# Do not print the warning message more than once$sgr0" \
" ${sgr1}source /path/to/ble.sh $bold--bash-debug-version=once$sgr0" \
'' \
" ${sgrC}# Show the warning message only once for each debug version of Bash$sgr0" \
" ${sgr1}source /path/to/ble.sh $bold--bash-debug-version=ignore$sgr0" \
''
fi
}
ble/base/check-bash-debug-version

#%x inc.r|@|src/decode|
#%x inc.r|@|src/color|
#%x inc.r|@|src/canvas|
Expand Down
12 changes: 7 additions & 5 deletions docs/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@

## New features

- Bash 5.3 support
- syntax: support bash-5.3 function subst `${ list; }` `#2045` 0906fd95 71272a4b
- decode(bind): support the colonless form of `bind -x` of bash-5.3 `#D2106` 78d7d2e3
- util(joblist): fix job detection in Bash 5.3 `#D2157` 6d835818
- util(joblist): exclude more foreground dead jobs in Bash 5.3 `#D2174` 8a321424
- global: work around function names with slashes in Bash 5.3 POSIX mode `#D2221` xxxxxxxx
- main: update the startup message for debug versions of Bash `#D2222` xxxxxxxx
- bgproc: support opts `kill9-timeout=TIMEOUT` `#D2034` 3ab41652
- progcomp(cd): change display name and support mandb desc (requested by EmilySeville7cfg) `#D2039` 74402098
- cmdspec: add completion options for builtins (motivated by EmilySeville7cfg) `#D2040` 9bd24691
- syntax: support bash-5.3 function subst `${ list; }` `#2045` 0906fd95 71272a4b
- complete: support `bleopt complete_requote_threshold` (requested by rauldipeas) `#2048` bb7e118e
- menu (`ble/widget/menu/append-arg`): add option `bell` (motivated by bkerin) `#D2066` 3f31be18 bbf3fed3
- make: support `make uninstall` `#D2068` a39a4a89
Expand Down Expand Up @@ -126,7 +132,6 @@
- decode,syntax: quote `$#` in arguments properly `#D2097` 40a625d3
- global: work around case-interleaving collation (reported by dongxi8) `#D2103` a3b94bb3
- nsearch: set `immediate-accept` for `empty=emulate-readline` (reported by blackteahamburger) `#D2104` 870ecef7
- decode(bind): support the colonless form of `bind -x` of bash-5.3 `#D2106` 78d7d2e3
- decode, vi_digraph: trim CR of text resources in MSYS `#D2105` 6f4badf4
- progcomp: conditionally suffix space for git completion (reported by bkerin) `#D2111` 2c7cca2f
- main: fix initialization errors with `set -u` `#D2116` b503887a
Expand All @@ -137,8 +142,6 @@
- main: work around nRF Connect initialization (requested by liyafe1997) `#D2129` 2df3b109
- main(unload): redirect streams to work around trap `EXIT` in bash-5.2 (reported by ragnarov) `#D2142` 38a8d571
- complete: call the `docker` command through `ble/util/conditional-sync` `#D2150` 6c3f824a
- util(joblist): fix job detection in Bash 5.3 `#D2157` 6d835818
- util(joblist): exclude more foreground dead jobs in Bash 5.3 `#D2174` 8a321424
- util,complete: work around regex `/=.../` failing in Solaris nawk `#D2162` 46fdf44a
- main: fix issues in MSYS1 `#D2163` 5f0b88fb
- util: work around bash-3.1 bug that `10>&-` fails to close the fd `#D2164` b5938192
Expand All @@ -147,7 +150,6 @@
- main: work around WSL's permission issue on `/run/user/1000` (reported by antonioetv and geoffreyvanwyk) `#D2195` fb826ab6
- util: detect Zellij heuristically `#D2219` xxxxxxxx
- decode: exclude `/etc/inputrc` in SUSE as well as in openSUSE (reported by Anyborr) `#D2220` xxxxxxxx
- global: work around function names with slashes in Bash 5.3 POSIX mode `#D2221` xxxxxxxx

## Contrib

Expand Down
26 changes: 26 additions & 0 deletions note.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7380,6 +7380,32 @@ bash_tips
Done (実装ログ)
-------------------------------------------------------------------------------

2024-06-11

* main: 5.3 check. 表示しない様にするオプションを追加する。説明追加 [#D2222]

* "bleopt init_check_debug_bash" 等にする? 然し、このチェックを行っている時
点では未だ bleopt/declare の仕組みを整えていないし、blerc も実行していな
い。だとすると、この表示を無効化するには source する時の引数として

source /path/to/ble.sh -o init_check_debug_bash=false

等としなければならない。或いは設定ではなくてオプションにしてしまう?

うーん。そちらの方が自然の気がしてきた。

然し、各 version で最低一回は表示する様にしようと思ったら結局
_ble_base_cache の初期化後にしなければならないので、それならば .blerc を
実行してからでも良いのでは? 現在の指定方法の候補は:

bleopt init_bash_debug_version={check,check-once,ignore}
ble.sh --bash-debug-version={check,check-once,ignore}

等の様すれば良い。うーん。初期化時だけに有効という事であればやはりオプショ
ンで良いのではないか。bleopt にしてもそのセッションでそれ以降に参照する事
はない。そして、_ble_base_cache が初期化できたらその後に実行すれば良い気
がする。

2024-06-05

* global: bash-5.3 posix function name with slashes in POSIX mode [#D2221]
Expand Down

0 comments on commit afb2907

Please sign in to comment.