Skip to content

Commit

Permalink
util(ble/util/eval-pathname-expansion): fix restoring shopt options i…
Browse files Browse the repository at this point in the history
…n bash-4.0
  • Loading branch information
akinomyoga committed Jun 27, 2022
1 parent f629698 commit 736f4da
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
5 changes: 3 additions & 2 deletions docs/ChangeLog.md
Expand Up @@ -101,8 +101,8 @@
- prompt: fix wrongly escaped UTF-8 chars in `\w` and `\W` `#D1806` d340233
- emacs: support `bleopt keymap_emacs_mode_string_multiline` (motivated by ArianaAsl) `#D1818` 8e9d273
- util: synchronize rlvars with `bleopt complete_{menu_color{,_match},skip_matched} term_bracketed_paste_mode` (motivated by ArianaAsl) `#D1819` 6d20f51
- util: suppress false warnings of `bind` inside non-interactive shells (reported by wukuan405) `#D1823` XXXXXXX
- history: support `bleopt history_erasedups_limit` (motivated by SuperSandro2000) `#D1822` e4afb5a XXXXXXX
- util: suppress false warnings of `bind` inside non-interactive shells (reported by wukuan405) `#D1823` 1e19a67
- history: support `bleopt history_erasedups_limit` (motivated by SuperSandro2000) `#D1822` e4afb5a 3110967

## Changes

Expand Down Expand Up @@ -250,6 +250,7 @@
- complete: fix a bug that the default progcomp does not work properly `#D1722` 01643fa
- highlight: fix a bug that arrays without the element `0` is not highlighted `#D1721` b0a0b6f
- util (visible-bell): erase visible-bell before running external commands `#D1723` 0da0c1c
- util(`ble/util/eval-pathname-expansion`): fix restoring shopt options in bash-4.0 `#D1825` XXXXXXX
- util (`ble/function`): work around `shopt -u extglob` `#D1725` 952c388
- syntax: fix uninitialized syntax-highlighting in bash-3.2 `#D1731` e3f5bf7
- make: fix a bug that config update messages are removed on install `#D1736` 72d968f
Expand Down
11 changes: 10 additions & 1 deletion lib/test-util.sh
Expand Up @@ -2,7 +2,7 @@

ble-import lib/core-test

ble/test/start-section 'ble/util' 1223
ble/test/start-section 'ble/util' 1226

# bleopt

Expand Down Expand Up @@ -1576,6 +1576,15 @@ ble/test ble/util/is-running-in-subshell exit=1

# ble/util/is-cygwin-slow-glob
# ble/util/eval-pathname-expansion
(
shopt -s failglob
shopt -s nullglob
shopt -s extglob
ble/util/eval-pathname-expansion 'non-existent-*-file' canonical
ble/test 'shopt -q failglob'
ble/test 'shopt -q nullglob'
ble/test 'shopt -q extglob'
)
# ble/util/isprint+
# ble/util/strftime

Expand Down
12 changes: 12 additions & 0 deletions note.txt
Expand Up @@ -6428,6 +6428,18 @@ bash_tips
Done (実装ログ)
-------------------------------------------------------------------------------

2022-06-27

* util (eval-pathname-expansion): bash-4.0以下で shopt *glob がクリアされる [#D1825]

ble-0.3 backport で見ていたら気づいた。BASHOPTS (Bash 4.1+) を使って shopt
の状態を記録しているが、Bash 4.0 以下に対する分岐がない。0da0c1c で埋め込ま
れたバグである。visible-bell 消去時に glob 関連の shopt が全て unset されて
しまう事になる。修正した。

* 他の BASHOPTS 使用箇所は問題ないか → 他には ble.pp で使っているだけであ
る。そして ble.pp の使用箇所ではちゃんと分岐している。

2022-06-26

* debug: profiling 機能 (motivated by SuperSandro2000) [#D1824]
Expand Down
11 changes: 10 additions & 1 deletion src/util.sh
Expand Up @@ -3684,7 +3684,16 @@ function ble/util/eval-pathname-expansion {
local canon=
if [[ :$2: == *:canonical:* ]]; then
canon=1
local set=$- shopt=$BASHOPTS gignore=$GLOBIGNORE
local set=$- shopt gignore=$GLOBIGNORE
if ((_ble_bash>=40100)); then
shopt=$BASHOPTS
else
shopt=
shopt -q failglob && shopt=$shopt:failglob
shopt -q nullglob && shopt=$shopt:nullglob
shopt -q extglob && shopt=$shopt:extglob
shopt -q dotglob && shopt=$shopt:dotglob
fi
shopt -u failglob
shopt -s nullglob
shopt -s extglob
Expand Down

0 comments on commit 736f4da

Please sign in to comment.