Skip to content

Commit

Permalink
edit: fix error messages on accessing undo records in emacs mode (fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Feb 27, 2021
1 parent 054e5c1 commit e9be69e
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 7 deletions.
3 changes: 2 additions & 1 deletion memo/ChangeLog.md
Expand Up @@ -60,6 +60,7 @@
- mandb: improve extraction and cache for each locale `#D1480` 3588158
- decode (rlfunc): work around incomplete bytes in keyseq (reported by onelittlehope) `#D1483` 3559658 beb0383 37363be
- main: fix a bug that unset `IFS` is not correctly restored `#D1489` 808f6f7
- edit: fix error messages on accessing undo records in emacs mode (reported by rux616) `#D1497` 0000000

## Compatibility

Expand All @@ -81,7 +82,7 @@
- util, color (`bleopt`, `blehook`, `ble-color-setface`): support `--color` and fix `sgr0` contamination in non-color output `#D1466` 69248ff
- global: fix status check for read timeout `#D1467` e886883
- decode: move `{keymap/*. => lib/core-decode.*-}rlfunc.txt` and clean up files `#D1486` f7323b4
- Makefile: fix up f7323b4: restore rule for `keymap/*.txt` `#D1496` 000000
- Makefile: fix up f7323b4: restore rule for `keymap/*.txt` `#D1496` 054e5c1
- util, etc: ensure each function to work with arbitrary `IFS` `#D1490` `#D1491` 5f9adfe

<!---------------------------------------------------------------------------->
Expand Down
71 changes: 71 additions & 0 deletions note.txt
Expand Up @@ -3771,6 +3771,77 @@ bash_tips
Done (実装ログ)
-------------------------------------------------------------------------------

2021-02-27

* エラーメッセージ "bash: ((: '0': syntax error:" (reported by rux616) [#D1497]
https://github.com/akinomyoga/ble.sh/issues/92

[状況]

bash: ((: '0': syntax error: operand expected (error token is "'0'")

* 最近発生する様になったという事。

* 一度発生し始めると色々なキーを入力する度にメッセージが出るという事。

* RET TAB BS 及び function keys が全滅。0-9 や numpad key も駄目。
何故か # や & 等の記号は OK

これは decoder が関係している気がする→2021-02の変更点を探してみたが特に怪
しい所はない。

* 連想配列が配列に化けてしまって発生しているという可能性もある。
然し、連想配列の添字に quote 付きの文字列を指定する事があるだろうか。
そもそも連想配列の添字に指定した '' が除去の対象だったかどうか怪しい。
→試してみた所、どうやら展開の対象の様である。

最初は発生していなくて途中から発生する様になるというのも不思議な事である。

再現できた。というか空の blerc でも再現できた。どうも set -o vi だと発生し
なくて set -o emacs だと発生する様だ。

bleopt default_keymap=vi でも起きなくなる。
bleopt default_keymap=emacs; set -o vi だと起きる。
bleopt default_keymap=safe でも起こらない。

うーん。emacs.sh の問題かとも思ったが最近変更した内容に関係のありそうな箇所
は存在しない。だとすると別の場所で発生した問題が emacs.sh の中でたまたま見
える様になっただけと考えるのが自然だろうか。

取り敢えずなにかエラーメッセージが出ているという事はその場所を特定するとい
うのは簡単の筈である。

| 取り敢えず PROLOGUE と EPILOGUE の間だという事は分かった。decode byte 関
| 連ではない。home を押しても一組しかエラーメッセージが出てきていないという
| 事と、keymap safe, vi では発生していないという事から考えるに。だとすると
| 残っているのは widget 実行辺りなのだが、様々な widget で発生している事か
| ら __before_widget__ が怪しい。
|
| →確かに __before_widget__ だった。特に ble-edit/undo/add の中でエラーが
| 発生している。
|
| % 更に ble-edit/undo/.get-current-state の内部で実行が途絶えている。と思っ
| % たがそうでもなかった。その次の行の辺りだった。
| %
| % _ble_edit_undo_index に整数が入っている筈なのに history という文字列が入っ
| % ている。と思ったら勘違いだった。_ble_edit_sttr に history という文字列が
| % 入っているだけだった。
|
| やはり .get-current-state だった。調べると _ble_edit_undo_index の中に
| '0' という文字列が設定されている。これは何処から来るのか調べる必要がある。

分かった。配列を保存・復元する時に quote-words 的な処理で囲んだ要素を eval
で評価するべき所が単に split-words で評価していたのが原因。最初は
quote-words 的な処理にに書き換えたのが原因かと思ったが、逆で eval していた
所を split-words に書き換えてしまったのが原因だった。つまり、犯人は 5f9adfe
だった。IFS の調整として分割を全て split-words に置き換えた時に余分に書き換
えてしまったのが原因。

修正した。

* ok: 他に似たような書き換えミスがなかったかどうか確認してみたが大丈夫の様
である。

2021-02-24

* Makefile: keymap/*.txt に対する規則を削除してはいけなかった (reported by nihilismus) [#D1496]
Expand Down
11 changes: 5 additions & 6 deletions src/edit.sh
Expand Up @@ -5596,15 +5596,14 @@ function ble-edit/undo/.check-hindex {
# save
if [[ $_ble_edit_undo_hindex ]]; then
local uindex=${_ble_edit_undo_index:-${#_ble_edit_undo[@]}}
local q=\' Q="'\''" value
ble/util/sprintf value "'%s' " "$uindex" "${_ble_edit_undo[@]//$q/$Q}"
_ble_edit_undo_history[_ble_edit_undo_hindex]=$value
local ret; ble/string#quote-words "$uindex" "${_ble_edit_undo[@]}"
_ble_edit_undo_history[_ble_edit_undo_hindex]=$ret
fi

# load
if [[ ${_ble_edit_undo_history[hindex]} ]]; then
local data; ble/string#split-words data "${_ble_edit_undo_history[hindex]}"
_ble_edit_undo=("${data[@]:1}")
local -a data=()
builtin eval -- "data=(${_ble_edit_undo_history[hindex]})"
_ble_edit_undo_index=${data[0]}
else
_ble_edit_undo=()
Expand Down Expand Up @@ -5844,7 +5843,7 @@ function ble-edit/history/goto {

((index0==index1)) && return 0

if [[ $bleopt_history_share && ! $_ble_history_prefix && $_ble_decode_keymap != isearch ]]; then
if [[ $bleopt_history_share && ! $_ble_history_prefix && $_ble_decode_keymap != isearch ]]; then
# Note: isearch の途中の history/goto で履歴情報が書き換わると変な事になるので
# isearch では history_share による読み込みは行わない。
# 一方で nsearch や lastarg は過去の履歴項目を参照するが
Expand Down

0 comments on commit e9be69e

Please sign in to comment.