Skip to content

Commit

Permalink
complete (quote-insert.batch): fix regex escaping in bracket expr of awk
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Jan 9, 2022
1 parent 3e136a6 commit 8039b77
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
6 changes: 5 additions & 1 deletion .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
Expand Down
5 changes: 3 additions & 2 deletions docs/ChangeLog.md
Expand Up @@ -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 <kbd>DECSCUSR</kbd> 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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/core-complete.sh
Expand Up @@ -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)))
Expand Down
37 changes: 37 additions & 0 deletions note.txt
Expand Up @@ -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]
Expand Down

0 comments on commit 8039b77

Please sign in to comment.