Skip to content

Commit

Permalink
util (ble/string#escape-for-bash-specialchars): fix escaping of TAB
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Dec 19, 2021
1 parent b547a41 commit 7db3d2b
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 9 deletions.
15 changes: 8 additions & 7 deletions docs/ChangeLog.md
Expand Up @@ -83,8 +83,8 @@
- 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
- 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

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

Expand Down Expand Up @@ -259,7 +260,7 @@
- stty: do not remove keydefs for <kbd>C-u</kbd>, <kbd>C-v</kbd>, <kbd>C-w</kbd>, and <kbd>C-?</kbd> (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

Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions lib/test-util.sh
Expand Up @@ -748,6 +748,8 @@ function is-global() (readonly "$1"; ! local "$1" 2>/dev/null)
ret='\[hello\]\ \(world\)\ \{this\,is\}\ \<test\>'
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
Expand Down
36 changes: 35 additions & 1 deletion note.txt
Expand Up @@ -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 の状態がおかしい。
Expand Down Expand Up @@ -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 のどちらかの初期化の途中で、ディレクトリ所
Expand Down
2 changes: 1 addition & 1 deletion src/util.sh
Expand Up @@ -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 の時には戻す。
Expand Down

0 comments on commit 7db3d2b

Please sign in to comment.