Skip to content

Commit

Permalink
decode, vi_digraph: trim CR of text resources in MSYS
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Jan 2, 2024
1 parent b577659 commit 6f4badf
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 12 deletions.
2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ endif

MWGPP:=$(GAWK) -f make/mwg_pp.awk

# Note (): we had used "cp -p xxx out/xxx" to copy files to the build
# Note (#D2058): we had used "cp -p xxx out/xxx" to copy files to the build
# directory, but some filesystem (ecryptfs) has a bug that the subsecond
# timestamps are truncated causing an issue: make every time copies all the
# files into the subdirectory `out`. We give up using `cp -p` and instead copy
Expand Down
2 changes: 1 addition & 1 deletion contrib
Submodule contrib updated 1 files
+4 −4 README.md
11 changes: 6 additions & 5 deletions docs/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
- keymap/vi: fix the behavior of text-object for quotes in xmap (reported by Darukutsu) `#D2094` 5f9a44ec
- edit(redo): fix broken common prefix/suffix determination (reported by Darukutsu) `#D2098` c920ea65
- keymap/vi: improve text-object in omap for brackets (reported by Darukutsu) `#D2100` d1a1d538
- decode(bind): fix command-line argument parsing `#D2107` xxxxxxxx
- edit(gexec): fix a bug that `LINENO` is vanishing `#D2108` xxxxxxxx
- decode(bind): fix command-line argument parsing `#D2107` 57a13c3c
- edit(gexec): fix a bug that `LINENO` is vanishing `#D2108` b5776596

## Compatibility

Expand All @@ -70,8 +70,9 @@
- global: adjust bash options for utilities outside the ble context (motivated by jkemp814) `#D2092` 6b144de7
- decode,syntax: quote `$#` in arguments properly `#D2097` 40a625d3
- global: work around case-interleaving collation (reported by dongxi8) `#D2103` a3b94bb3
- nsearch: set `immediate-accept` for `empty=emulate-readline` (reported by blackteahamburger) `#D2104` xxxxxxxx
- decode(bind): support the colonless form of `bind -x` of bash-5.3 `#D2106` xxxxxxxx
- nsearch: set `immediate-accept` for `empty=emulate-readline` (reported by blackteahamburger) `#D2104` 870ecef7
- decode(bind): support the colonless form of `bind -x` of bash-5.3 `#D2106` 78d7d2e3
- decode, vi_digraph: trim CR of text resources in MSYS `#D2105` xxxxxxxx

## Contrib

Expand All @@ -92,7 +93,7 @@

- test(bash): fix condition for bash bug of history expansion `#D2071` aacf1462
- test(main): fix delimiter of `MSYS` in adding `winsymlinks` `#D2071` aacf1462
- test(util,vi): adjust `ble/util/is-stdin-ready` while testing `#D2105` xxxxxxxx
- test(util,vi): adjust `ble/util/is-stdin-ready` while testing `#D2105` 23a05827 xxxxxxxx

## Internal changes

Expand Down
1 change: 1 addition & 0 deletions lib/keymap.vi_digraph.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function ble-decode/keymap:vi_digraph/define {
local line field ch1 ch2 code
for line in "${lines[@]}"; do
[[ $line == ??' '* ]] || continue
[[ $OSTYPE == msys* ]] && line=${line%$'\r'}
ch1=${line::1}
ch2=${line:1:1}
code=${line:3}
Expand Down
14 changes: 9 additions & 5 deletions lib/test-util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1875,7 +1875,9 @@ fi
ble-import FILE1.txt FILE2.txt -C 'ble/util/print both1' -C 'ble/util/print both2'

(
ble/test 'ble/util/idle.do' stdout=
if ble/is-function ble/util/idle.push; then
ble/test 'ble/util/idle.do' stdout=
fi
ble/test 'ble-import FILE1.txt' stdout=$'FILE1\nloaded1\nloaded2\nloaded3\nloaded4'
ble/test 'ble-import FILE2.txt' stdout=$'FILE2\nboth1\nboth2'
)
Expand All @@ -1894,10 +1896,12 @@ fi
)

# with -d option
(
ble-import FILE1.txt FILE2.txt -dC 'ble/util/print both'
ble/test 'ble/util/idle.do' stdout=$'FILE1\nFILE2\nboth'
)
if ble/is-function ble/util/idle.push; then
(
ble-import FILE1.txt FILE2.txt -dC 'ble/util/print both'
ble/test 'ble/util/idle.do' stdout=$'FILE1\nFILE2\nboth'
)
fi

ble/test/rmdir
)
Expand Down
30 changes: 30 additions & 0 deletions note.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7333,6 +7333,36 @@ bash_tips
end-section でない時に正しく失敗が検出できていなかった。end-section 毎に失
敗 section 数をインクリメントする事にした。

2024-01-01 未だ失敗している。macos で失敗している。windows では一応成功はし
ているが変なエラーが発生している。macos の方については単に bash-3.2 だった
ので ble/util/idle.do が空実装になっていてそれを使ったテストが通っていない
だけだった。

windows の方についてはどうも rlfunc.txt の各行の末尾に \r がついているのが
原因の様だ。然し、調べてみるとその他のファイルについても全部 \r がついてい
る様に見える。何故問題になっていないのか。bash が読み取る時にいい具合にして
くれるという事なのだろうか。

? その他の自前で読み書きしているファイルについては大丈夫なのだろうか? →調
べてみた所、自前で生成したファイルについては大丈夫だった。

注意しなければならないファイルは rlfunc.txt, ignoreeof-messages.txt,
vi_digraph.txt である。rlfunc.txt については対策はできた。
ignoreeof-messages.txt については行内の何処かに一致していれば良いという作
戦なので、余分な \r がついていてもちゃんと動作する。vi_digraph.txt につい
ては mapfile で読み取っているのでちゃんと調整が必要になる。

? 或いは読み取る時の方法によって \r が除去されたりされなかったりする等の事
があるのだろうか? もし mapfile だけで問題が起きるのだとしたらそれについて
もちゃんと対策をする必要が出てくる。

既存のファイル keymap.vi_digraph.txt を使って確かめてみる事にした。実際に
keymap.vi_digraph.txt の中身も \r が付加されていて、更に read で読み取っ
たとしても \r が混入してしまうという事が確認できた。つまり、mapfile を使っ
たから悪いという訳ではない。

修正した。

* edit: history-search-backward に関する振る舞いに対する要望 (reported by blackteahamburger) [#D2104]
https://github.com/akinomyoga/ble.sh/issues/382

Expand Down
1 change: 1 addition & 0 deletions src/decode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3718,6 +3718,7 @@ function ble/builtin/bind/rlfunc2widget {
local line
for line in "${dict[@]}"; do
[[ $line == "$rlfunc "* ]] || continue
[[ $OSTYPE == msys* ]] && line=${line%$'\r'}
local rl widget; ble/bash/read rl widget <<< "$line"
if [[ $widget == - ]]; then
ble/util/print "ble.sh (bind): unsupported readline function '${rlfunc//$q/$Q}' for keymap '$kmap'." >&2
Expand Down

0 comments on commit 6f4badf

Please sign in to comment.