Skip to content

Commit

Permalink
util (ble/function#pop): allow popping unset function
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Jul 9, 2022
1 parent d5fe1d1 commit c0abc95
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion docs/ChangeLog.md
Expand Up @@ -338,6 +338,7 @@
- complete: work around a false warning messages of gawk-4.0.2 `#D1709` 9771693
- main: work around `XDG_RUNTIME_DIR` of a different user by `su` (reported by zim0369) `#D1712` 8d37048
- main (`ble/util/readlink`): work around non-standard or missing `readlink` (motivated by peterzky) `#D1720` a41279e
- util (`ble/function#pop`): allow popping unset function `#D1834` XXXXXXX
- menu (`menu-style:desc`): work around xenl quirks for relative cursor movements (reported by telometto) `#D1728` 3e136a6
- global: work around the arithmetic syntax error of `10#` in Bash-5.1 `#D1734` 7545ea3
- global: adjust implementations for Bash 5.2 `patsub_replacement` `#D1738` 4590997
Expand All @@ -363,7 +364,7 @@
- progcomp: work around the cobra V2 description hack (reported by SuperSandro2000) `#D1803` 71d0736
- complete: work around blocking `_scp_remote_files` and `_dnf` (reported by iantra) `#D1807` a4a779e 46f5c13
- history: work around broken timestamps in `HISTFILE` (reported by johnyaku) `#D1831` 5ef28eb
- progcomp: disable `command_not_found_handle` (reported by telometto, wisnoskij) `#D1834` 64d471a XXXXXXX
- progcomp: disable `command_not_found_handle` (reported by telometto, wisnoskij) `#D1834` 64d471a d5fe1d1

## Internal changes and fixes

Expand Down
9 changes: 9 additions & 0 deletions note.txt
Expand Up @@ -6586,6 +6586,15 @@ bash_tips
で寧ろ入力ではなくて出力の方を組み替えている。なのに出力は出来て入力は
できないというのも変な事である。

* 2022-07-09 使っていたら元から command_not_found_handle が定義されていなかっ
た時に pop 時に問題が発生する。これは ble/function#{push,pop} の実装の問
題である。

これは function#push 時に関数定義を与えなかった時に関数を unset する機能
を導入した時の手落ちと考えられる。調べてみるとこれは a41279e (#D1720) に
おける変更である。この時に一応 function#pop に対しても対応する変更がなさ
れているが、それが不完全だったという事。

2022-07-07

* main: fd 0, 1 が TTY かどうかのチェックが常に偽になっている [#D1833]
Expand Down
6 changes: 4 additions & 2 deletions src/util.sh
Expand Up @@ -3141,9 +3141,11 @@ function ble/function#pop {
if ble/is-function "$name"; then
builtin unset -f "$name"
return 0
else
ble/util/print "ble/function#push: $name is not a function." >&2
elif ble/bin#has "$name"; then
ble/util/print "ble/function#pop: $name is not a function." >&2
return 1
else
return 0
fi
else
local def; ble/function#getdef "ble/function#push/$index:$name"
Expand Down

0 comments on commit c0abc95

Please sign in to comment.