From 1f2d45fa619a0b17b1687742f735d182d7220d9d Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Fri, 4 Jun 2021 11:32:17 +0900 Subject: [PATCH] progcomp: fix a bug that command names may stray into completer function names --- lib/core-complete.sh | 7 ++++--- memo/ChangeLog.md | 1 + note.txt | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/core-complete.sh b/lib/core-complete.sh index 5dc8ac8a..4911ac6c 100644 --- a/lib/core-complete.sh +++ b/lib/core-complete.sh @@ -2501,6 +2501,7 @@ function ble/complete/progcomp/.compgen { elif ble/syntax:bash/simple-word/is-simple "$compcmd"; then # 既に呼び出し元で quote されている想定 ble/util/assign compdef "builtin complete -p -- $compcmd 2>/dev/null" + local ret; ble/syntax:bash/simple-word/eval "$compcmd"; compcmd=$ret else ble/util/assign compdef 'builtin complete -p -- "$compcmd" 2>/dev/null' fi @@ -2728,7 +2729,7 @@ function ble/complete/progcomp { ucmd=$cmd qcmds=("$cmd") if ble/syntax:bash/simple-word/is-simple "$cmd" && ble/syntax:bash/simple-word/eval "$cmd" noglob && - [[ $ret != "$cmd" || ${#ret[0]} -ne 1 ]]; then + [[ $ret != "$cmd" || ${#ret} -ne 1 ]]; then ucmd=${ret[0]} qcmds=() local word @@ -4522,7 +4523,7 @@ function ble/complete/menu/generate-candidates-from-menu { # remaining candidates cand_count=${#_ble_complete_menu_items[@]} cand_cand=() cand_word=() cand_pack=() - local pack "${_ble_complete_cand_varnames[@]/=}" # #D1570 WA checked + local pack "${_ble_complete_cand_varnames[@]/%/=}" # #D1570 WA checked for pack in "${_ble_complete_menu_items[@]}"; do ble/complete/cand/unpack "$pack" ble/array#push cand_cand "$CAND" @@ -5340,7 +5341,7 @@ function ble/complete/menu-filter/.filter-candidates { cand_pack=() local iloop=0 interval=$bleopt_complete_polling_cycle - local filter_type pack "${_ble_complete_cand_varnames[@]/=}" # #D1570 WA checked + local filter_type pack "${_ble_complete_cand_varnames[@]/%/=}" # #D1570 WA checked for filter_type in head substr hsubseq subseq; do ble/path#remove-glob comp_type '[maA]' case $filter_type in diff --git a/memo/ChangeLog.md b/memo/ChangeLog.md index ebc9b7f4..5b00c32c 100644 --- a/memo/ChangeLog.md +++ b/memo/ChangeLog.md @@ -58,6 +58,7 @@ - util (`bleopt`): do no select obsoleted options by wildcards `#D1595` f4312df - util (`bleopt`): fix error messages for unknown options `#D1610` 0000000 - progcomp: support quoted commands and better `progcomp_alias` `#D1581` `#D1583` dbe87c3 + - progcomp: fix a bug that command names may stray into completer function names `#D1611` 0000000 - syntax: highlight quotes of the `\?` form `#D1584` 5076a03 - prompt: support a new backslash sequence `\g{...}` `#D1609` 0000000 diff --git a/note.txt b/note.txt index c3b7c3c6..e73cb8d7 100644 --- a/note.txt +++ b/note.txt @@ -4683,6 +4683,21 @@ bash_tips 2021-06-12 + * complete: "complete -p" 解析の修正 + 細かい修正 [#D1611] + + complete に対する細かい修正が溜まっているのでいい加減に push する。 + + * 一つは quote された progcomp が正しく unquote されずに続く complete -p + の関数名抽出に渡っている問題の修正。 + + 他は m scan に関連する軽微なミスである。 + + * local "${_ble_complete_cand_varnames[@]}" の localvar_inherit に対する対 + 策が間違っている問題。 + + * 文字数を数えるのに ${#ret[0]} の形式を使ってしまっている問題 (bash-3.0 + bug) + * util: bleopt の unknown option の表示が空になる [#D1610] bleopt で誤ったオプション名を指定した時のエラーメッセージでオプション名が空