Skip to content

Commit

Permalink
edit (ble/widget/display-shell-version): print shell options
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Aug 23, 2024
1 parent 5a8dcb4 commit 70b89e5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions note.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
20 changes: 20 additions & 0 deletions src/edit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 70b89e5

Please sign in to comment.