diff --git a/lib/core-complete.sh b/lib/core-complete.sh index 33c2ce59..60506e27 100644 --- a/lib/core-complete.sh +++ b/lib/core-complete.sh @@ -1405,7 +1405,9 @@ function ble/complete/source:argument/.progcomp { else ble/util/assign compdef 'complete -p -- "$compcmd" 2>/dev/null' fi - compdef=${compdef%"$compcmd"} # strip -I, -D, or command_name + # strip -I, -D, or command_name + # #D1579 bash-5.1 では空コマンドに限り '' と出力する様である。 + compdef=${compdef%"${compcmd:-''}"} compdef=${compdef%' '}' ' local comp_prog comp_func compoptions flag_noquote diff --git a/lib/core-syntax.sh b/lib/core-syntax.sh index e17011a5..52a0c06e 100644 --- a/lib/core-syntax.sh +++ b/lib/core-syntax.sh @@ -4581,9 +4581,18 @@ function ble/syntax/completion-context/.check-prefix/ctx:quote/.check-container- local wlen2=${nest[1]}; ((wlen2>=0)) || return local wbeg2=$((wlen2<0?wlen2:inest-wlen2)) - if ble/syntax:bash/simple-word/is-simple-or-open-simple "${text:wbeg2:index-wbeg2}"; then - ble/syntax/completion-context/.add argument "$wbeg2" + local wt=${nest[2]} + [[ ${_ble_syntax_bash_command_EndWtype[wt]} ]] && + wt=${_ble_syntax_bash_command_EndWtype[wt]} + if ((wt==CTX_CMDI)); then + ble/syntax/completion-context/.add command "$wbeg2" + elif ((wt==CTX_ARGI||wt==CTX_ARGVI||wt==CTX_ARGEI||wt==CTX_FARGI2||wt==CTX_CARGI2)); then + ble/syntax/completion-context/.add argument "$wbeg2" + elif ((wt==CTX_CPATI)); then # case pattern の内部 + #ble/syntax/completion-context/.add file "$wbeg2" + return + fi fi }