From 8039b777df6e5308525910bb637d0e84c1a5f1f5 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Sun, 9 Jan 2022 09:01:55 +0900 Subject: [PATCH] complete (quote-insert.batch): fix regex escaping in bracket expr of awk --- .srcoption | 6 +++++- docs/ChangeLog.md | 5 +++-- lib/core-complete.sh | 2 +- note.txt | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 4 deletions(-) diff --git a/.srcoption b/.srcoption index dbf2dc95..3b5d6510 100644 --- a/.srcoption +++ b/.srcoption @@ -1,4 +1,8 @@ --x md:bash --exclude=./out --exclude=./dist --exclude=./a.sh --exclude=./test/install --exclude=./ble.sh +-x md:bash +--exclude=./{out,dist,tmp} +--exclude=./?.sh +--exclude=./test/install +--exclude=./ble.sh GNUmakefile ble.pp blerc diff --git a/docs/ChangeLog.md b/docs/ChangeLog.md index 80295eb5..9aafbdc4 100644 --- a/docs/ChangeLog.md +++ b/docs/ChangeLog.md @@ -80,7 +80,7 @@ - blerc: fix the name of the option `bleopt canvas_winch_action` (reported by Knusper) b1be640 - menu (menu-style:desc): improve descriptions (motivated by Shahabaz-Bagwan) `#D1685` 4de1b45 - menu (menu-style:desc): support multicolumns (motivated by Shahabaz-Bagwan) `#D1686` 231dc39 - - menu (menu-style:desc): fix not working `bleopt menu_desc_multicolumn_width=` `#D1727` 0000000 + - menu (menu-style:desc): fix not working `bleopt menu_desc_multicolumn_width=` `#D1727` 2140d1e - term: let DECSCUSR pass through terminal multiplexers (motivated by cmplstofB) `#D1697` a3349e4 - complete: requote for more compact representations on full completions `#D1700` a1859b6 - complete: improve support for `declare` and `[[ ... ]]` `#D1701` da38404 @@ -245,6 +245,7 @@ - prompt: fix not properly set `$?` in `${PS1@P}` evaluation (reported by nihilismus) `#D1644` 521aff9 - decode: cache `inputrc` translations `#D1652` 994e2a5 - complete: use `awk` for batch `quote-insert` (motivated by banoris) `#D1714` a0b2ad2 92d9734 + - complete (quote-insert.batch): fix regex escaping in bracket expr of awk (reported by telometto) `#D1729` 0000000 ## Compatibility @@ -278,7 +279,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 -- menu (`menu-style:desc`): work around xenl quirks for relative cursor movements `#D1728` 0000000 +- menu (`menu-style:desc`): work around xenl quirks for relative cursor movements (reported by telometto) `#D1728` 3e136a6 ## Internal changes and fixes diff --git a/lib/core-complete.sh b/lib/core-complete.sh index 8cd40a21..d89eb69b 100644 --- a/lib/core-complete.sh +++ b/lib/core-complete.sh @@ -1419,7 +1419,7 @@ function ble/complete/action/quote-insert.batch/awk { gsub(/[\\"$`]/, "\\\\&", text); # Note: All awks behaves the same for "\\\\&" } else if (escape_type == 4) { # bash specialchars - gsub(/[]\ "'$q'`$|&;<>()!^*?[]/, "\\\\&", text); + gsub(/[]\\ "'$q'`$|&;<>()!^*?[]/, "\\\\&", text); if (escape_c) gsub(/[=:]/, "\\\\&", text); if (escape_b) gsub(/[{,}]/, "\\\\&", text); if (ret ~ /^~/ && (escape_tilde_always || escape_tilde_exists && exists(cand))) diff --git a/note.txt b/note.txt index 50878466..1d72c131 100644 --- a/note.txt +++ b/note.txt @@ -5795,6 +5795,43 @@ bash_tips Done (実装ログ) ------------------------------------------------------------------------------- +2022-01-09 + + * complete: gawk regex warning (reported by telometto) [#D1729] + https://github.com/akinomyoga/ble.sh/issues/167 + + これは最近追加した ble/complete/action/quote-insert.batch/awk から出ていた。 + awk の bracket expression の中のエスケープシーケンスは解釈されるのだった。 + なので孤立した \ から警告が発生していた。普段 nawk を使っていたので気づかな + かった。取り敢えず修正した。 + + ? 他にも類似の問題が別の箇所にあったりはしないだろうか。念の為、全ての + ble/bin/awk のスクリプトを gawk に食わせて見た方が良いのかもしれない。然 + しチェックするとしてもどうやってチェックするのか。個別にスクリプトを実行 + するのは面倒だし、スクリプトを実行する事によってファイルが作られたりして + しまうかもしれない。また関連する変数などをちゃんと初期化しなければスクリ + プトを正しく再現できないかもしれないし、実行時に正規表現が構築されている + 場合にも影響を与える (実行時に正規表現が構築される事はなかった様な気もす + るが)。 + + 一応 bracket expression を含む正規表現を他から取得している箇所だけは再確 + 認する。特に parse_help の辺り。 + + * _ble_complete_option_chars は既にちゃんと対策されていて注記まであった。 + * 他にもう一箇所 [] の中に \ がある物があったが其処もちゃんと \\ になって + いた。 + + \ を全体に渡って検索してみたが core-complete の中には他には怪しい物はなかっ + た。 + + * benchmark.sh にはない。 + * history.sh にも沢山 [\\] や [^...\\] があったが、これらもちゃんとエスケー + プされている。 + * decode.sh にも幾らかあった。綺麗に awk の中と外でちゃんと \\ と \ が使 + い分けられている。 + * util.sh もちゃんと使い分けられている。 + * edit.sh にはない。ble.pp もない。contrib/prompt-git.bash も大丈夫。 + 2022-01-08 * complete: WA terminal glitch on xenl (reported by telometto) [#D1728]