diff --git a/docs/ChangeLog.md b/docs/ChangeLog.md index c21e4f1c..35931551 100644 --- a/docs/ChangeLog.md +++ b/docs/ChangeLog.md @@ -57,6 +57,7 @@ - progcomp: support `complete -E` `#D2257` ffac4205 - make: support make variable `USE_DOC=no` (requested by blackteahamburger) `#D2260` 40fe9c95 - make: fix condition for the INSDIR_LICENSE rule (reported by Jai-JAP) `#D2260` xxxxxxxx +- edit (`ble/widget/display-shell-version`): print shell options `#D2260` xxxxxxxx ## Changes diff --git a/note.txt b/note.txt index a1955d13..0aaa584e 100644 --- a/note.txt +++ b/note.txt @@ -7371,6 +7371,13 @@ bash_tips Done (実装ログ) ------------------------------------------------------------------------------- +2024-08-24 + + * edit: display-shell-version に SHELLOPTS, BASHOPTS も含めるべき? [#D2261] + + 追加した。diff が使える時は diff を使って既定のオプションと異なる物だけを指 + 定する。 + 2024-08-23 * make: make variable "USE_DOC=no" (requested by blackteahamburger) [#D2260] diff --git a/src/edit.sh b/src/edit.sh index ee0382e5..97d9c73b 100644 --- a/src/edit.sh +++ b/src/edit.sh @@ -4446,6 +4446,26 @@ function ble/widget/display-shell-version { done lines[iline++]=$line + # shell options + if ble/bin#freeze-utility-path diff && [[ -x $BASH ]]; then + local _ble_local_tmpfile + ble/util/assign/mktmp; local tmpfile1=$_ble_local_tmpfile + ble/util/assign/mktmp; local tmpfile2=$_ble_local_tmpfile + + "$BASH" --norc --noprofile -ic 'shopt -po; shopt' >| "$tmpfile1" + { shopt -po; shopt; } >| "$tmpfile2" + local awk_script='/^[-+].*[[:space:]]on$/ {print $1} /^[-+]set -o .*$/ {print substr($0,1,1) $3}' IFS=$' \t\n' + ble/util/assign-words diff 'ble/bin/diff -bwu "$tmpfile1" "$tmpfile2" | ble/bin/awk "$awk_script"' + line="${_ble_term_bold}options$sgr0: ${diff[*]}" + + _ble_local_tmpfile=$tmpfile2 ble/util/assign/rmtmp + _ble_local_tmpfile=$tmpfile1 ble/util/assign/rmtmp + else + line="${_ble_term_bold}options$sgr0: ${sgr2}SHELLOPTS$sgrV=$sgr0$SHELLOPTS" + ((_ble_bash>=40100)) && line="$line, ${sgr2}BASHOPTS$sgrV=$sgr0$BASHOPTS" + fi + lines[iline++]=$line + ble/widget/print "${lines[@]}" [[ $_ble_bash_options_adjusted ]] || ble/base/.restore-bash-options set shopt