From 7db3d2bd2ee53e0a16016f07df9da802e1cc1240 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Sat, 18 Dec 2021 16:43:44 +0900 Subject: [PATCH] util (ble/string#escape-for-bash-specialchars): fix escaping of TAB --- docs/ChangeLog.md | 15 ++++++++------- lib/test-util.sh | 2 ++ note.txt | 36 +++++++++++++++++++++++++++++++++++- src/util.sh | 2 +- 4 files changed, 46 insertions(+), 9 deletions(-) diff --git a/docs/ChangeLog.md b/docs/ChangeLog.md index 960040a3..6a7b8d98 100644 --- a/docs/ChangeLog.md +++ b/docs/ChangeLog.md @@ -83,8 +83,8 @@ - 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 - - syntax: fix completion and highlighting of `declare` with assignment arguments `#D1704` `#D1705` 0000000 - - cmdspec: refactor `{mandb => cmdspec}_opts` `#D1706` `#D1707` 0000000 + - syntax: fix completion and highlighting of `declare` with assignment arguments `#D1704` `#D1705` e12bae4 + - cmdspec: refactor `{mandb => cmdspec}_opts` `#D1706` `#D1707` 0786e92 ## Changes @@ -146,7 +146,7 @@ - mandb: support the man-page formats of `wget`, `fish`, and `ping` (reported by bbyfacekiller) `#D1687` a79280e - mandb: carry optarg for e.g. `-a, --accept=LIST` `#D1687` 23d5657 - mandb: parse `--help` for specified commands `#D1693` e1ad2f1 - - mandb: fix small issues of man-page analysis `#D1708` 0000000 + - mandb: fix small issues of man-page analysis `#D1708` caa77bc - edit: work around the wrong job information of Bash in trap handlers (reported by 3ximus) `#D1435` `#D1436` bc4735e - edit (command-help): work around the Bash bug that tempenv vanishes with `builtin eval` `#D1438` 8379d4a - global: suppress missing locale errors (reported by 3ximus) `#D1440` 4d3c595 @@ -202,8 +202,9 @@ - util (`ble/util/readfile`): fix a bug of always exiting with 1 in `bash <= 3.2` (reported by laoshaw) `#D1678` 61705bf - trace: fix wrong positioning of the ellipses on overflow `#D1684` b90ac78 - complete: do not generate keywords for quoted command names `#D1691` 60d244f -- complete: fix empty completions with `FIGNORE` (reported by seanfarley) `#D1711` 0000000 - +- complete: fix empty completions with `FIGNORE` (reported by seanfarley) `#D1711` 144ea5d +- main: fix the message of owner errors of cache directories (reported by zim0369) `#D1712` b547a41 +- util (`ble/string#escape-for-bash-specialchars`): fix escaping of TAB `#D1713` 0000000 ## Documentation @@ -259,7 +260,7 @@ - stty: do not remove keydefs for C-u, C-v, C-w, and C-? (reported by laoshaw) `#D1683` 82f74f0 - builtin: print usages of emulated builtins on option errors `#D1694` 6f74021 - decode (`ble/builtin/bind`): improve compatibility of the deprecated form `bind key:rlfunc` (motivated by cmplstofB) `#D1698` b6fc4f0 -- complete: work around a false warning messages of gawk-4.0.2 `#D1709` 0000000 +- complete: work around a false warning messages of gawk-4.0.2 `#D1709` 9771693 ## Internal changes and fixes @@ -287,7 +288,7 @@ - util: fix leak variables `buff`, `trap`, `{x,y}{1,2}` `#D1572` 5967d6c - util: fix leak variables `#D1643` fcf634b - edit (`command-help`): use `ble/util/assign/.mktmp` to determine the temporary filename `#D1663` 1af0800 -- make: update lint check `#D1709` 0000000 +- make: update lint check `#D1709` 7e26dcd # ble-0.4.0-devel2 diff --git a/lib/test-util.sh b/lib/test-util.sh index 27a9ae32..e76a8197 100644 --- a/lib/test-util.sh +++ b/lib/test-util.sh @@ -748,6 +748,8 @@ function is-global() (readonly "$1"; ! local "$1" 2>/dev/null) ret='\[hello\]\ \(world\)\ \{this\,is\}\ \' ble/test 'ble/string#escape-for-bash-specialchars "a=b:c:d" c' \ ret='a\=b\:c\:d' + ble/test $'ble/string#escape-for-bash-specialchars "a\tb\tc"' \ + ret=$'a\\\tb\\\tc' ) # ble/string#quote-command, ble/util/print-quoted-command diff --git a/note.txt b/note.txt index 26cda3bc..fc55dd01 100644 --- a/note.txt +++ b/note.txt @@ -1633,6 +1633,25 @@ bash_tips ToDo ------------------------------------------------------------------------------- +2021-12-18 + + * complete: FIGNORE と -o filenames + + どうやら元の bash では -o filenames が指定された時にのみ FIGNORE が使われる + 様である。一方で、現在の ble.sh では FIGNORE が設定されている時には強制的に + fignore が実行される様になっている気がする。と思ったらこれは shopt -s + force_fignore の設定を参照しての事だった。よく分からないのは bash は + force_fignore が設定されていても、-o filenames が指定されていなければ + FIGNORE が有効にならない様だという事。 + + * FIGNORE で全て候補が消えた場合には FIGNORE を無効化して全て採択するべきで + は? と思ったが元の bash ではその様な取り扱いはしていない。 + + * Note: bash FIGNORE は glob は解釈しない。bash FIGNORE はそれが実際には存 + 在しないファイル名だったとしても、FIGNORE に一致すれば候補削除する。bash + FIGNORE は候補が FIGNORE で全滅してもそのまま。bash FIGNORE は単一候補だっ + た時にも FIGNORE を適用して候補を消す。 + 2021-12-14 * compat: RLogin で ble-detach した後に modifyOtherKeys の状態がおかしい。 @@ -5668,7 +5687,22 @@ bash_tips 2021-12-18 - * main: root ユーザーで入ると the owner of '' is not correct と表示される [#D1712] + * ble/string#escape-for-bash-specialchars で HT を SP HT に置換しているのは何故? [#D1713] + manu-complete 最適化中に気づいた事。 + + e344a156 ble-core.sh (Koichi Murase 2018-08-06 13:43:50 +0900 1135) a=$'\t' b=$' \t' ret=${ret//"$a"/$b} + 9629b9dd lib/core-complete.sh (Koichi Murase 2018-08-05 15:28:25 +0900 75) a=$'\t' b="\\$a" ret=${ret//"$a"/$b} + + うーん。これを見ると e344a156 のリファクタリング時のミスの様な気がする。該 + 当する項目は #D0719 であるが、たった一行で済ませているという事を考えるとこ + れは本当にミスであると判定して良い。というかそもそも元々の実装自体が間違っ + ている。 + + 改行と同様に $'\t' に置き換えるという手と、恐らく現在・以前の実装で意図して + いたと思われる \[TAB] という形に置き換えるという二つの方針が考えられる。本 + 来意図していた筈の後者にする事にする。 + + * main: root ユーザーで入ると the owner of '' is not correct と表示される (reported by zim0369) [#D1712] https://github.com/akinomyoga/ble.sh/issues/163 _ble_base_run か _ble_base_cache のどちらかの初期化の途中で、ディレクトリ所 diff --git a/src/util.sh b/src/util.sh index 5eff3583..5dc5e4cb 100644 --- a/src/util.sh +++ b/src/util.sh @@ -1132,7 +1132,7 @@ function ble/string#escape-for-bash-specialchars { local a b a=']' b=\\$a ret=${ret//"$a"/$b} a=$'\n' b="\$'\n'" ret=${ret//"$a"/$b} - a=$'\t' b=$' \t' ret=${ret//"$a"/$b} + a=$'\t' b=$'\\\t' ret=${ret//"$a"/$b} fi # 上の処理で extglob の ( も quote されてしまうので G の時には戻す。