Skip to content

Commit

Permalink
progcomp: fix a bug that command names may stray into completer funct…
Browse files Browse the repository at this point in the history
…ion names
  • Loading branch information
akinomyoga committed Jun 12, 2021
1 parent 66df3e2 commit 1f2d45f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/core-complete.sh
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions memo/ChangeLog.md
Expand Up @@ -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

Expand Down
15 changes: 15 additions & 0 deletions note.txt
Expand Up @@ -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 で誤ったオプション名を指定した時のエラーメッセージでオプション名が空
Expand Down

0 comments on commit 1f2d45f

Please sign in to comment.