diff --git a/docs/ChangeLog.md b/docs/ChangeLog.md index 8b6dab18..5850f38b 100644 --- a/docs/ChangeLog.md +++ b/docs/ChangeLog.md @@ -160,6 +160,7 @@ - util (`blehook`): fix a bug that the the hook arguments are lost (reported by SuperSandro2000) `#D1804` 479795d - complete (`source:command/get-desc`): show function location and body `#D1788` 496e798 - edit (`ble-detach`): prepend a space to `stty sane` for `HISTIGNORE=' *'` `#D1796` 26b532e +- decode (bind): do not treat non-beginning `#` as comments `#D1820` XXXXXXX ## Fixes diff --git a/note.txt b/note.txt index 246bdd47..b60e6300 100644 --- a/note.txt +++ b/note.txt @@ -6431,6 +6431,18 @@ bash_tips 2022-06-19 + * decode (bind): inputrc に含まれる # の処理 [#D1820] + + % 変数によって処理したり処理しなかったりの様だ。特に文字列を受け取るオプショ + % ンに関しては # 以降の削除はされない。一方で on/off のオプションの場合には + % '#' 以降は無視されている様に見える。→と思ったが違った。単に最初の空白で + % 切っているだけだった。 + + Bash-5.1 以降では on/off オプションについては空白で区切った最初の単語だけを + 見る。Bash-5.0 以前は (# が含まれていたとしても) 全体を見る。うーん。ble.sh + 内部では勝手に '#' 以降を削除してから処理しているがこれは正しくない。後で修 + 正する。これは 0.3 以前に遡って適用する。 + * util: rlvar enable-bracketed-paste off に対応する (motivated by ArianaAsl) [#D1819] https://github.com/akinomyoga/ble.sh/discussions/199 diff --git a/src/decode.sh b/src/decode.sh index 3bf1277a..4c5ddef4 100644 --- a/src/decode.sh +++ b/src/decode.sh @@ -3595,10 +3595,15 @@ function ble/builtin/bind/option:u/search-recursive { function ble/builtin/bind/option:- { local ret; ble/string#trim "$1"; local arg=$ret - # コメント除去 (quote されていない "空白+#" 以降はコメント) - local q=\' ifs=$_ble_term_IFS - local rex='^(([^\"'$q$ifs']|"([^\"]|\\.)*"|'$q'([^\'$q']|\\.)*'$q'|\\.|['$ifs']+[^#'$_ifs'])*)['$ifs']+#' - [[ $arg =~ $rex ]] && arg=${BASH_REMATCH[1]} + # Note (#D1820): これまで行の途中から始まるコメントを除去していたが、実際に + # inputrc 色々書き込んで調べると特に無視されている訳では無い事が分かった。 + # なので、行頭に # がある場合にのみ処理を中断することにする。 + [[ ! $arg || $arg == '#'* ]] && return 0 + + # # コメント除去 (quote されていない "空白+#" 以降はコメント) + # local q=\' ifs=$_ble_term_IFS + # local rex='^(([^\"'$q$ifs']|"([^\"]|\\.)*"|'$q'([^\'$q']|\\.)*'$q'|\\.|['$ifs']+[^#'$_ifs'])*)['$ifs']+#' + # [[ $arg =~ $rex ]] && arg=${BASH_REMATCH[1]} local ifs=$_ble_term_IFS if [[ $arg == 'set'["$ifs"]* ]]; then