I've got a completion function which at some point is supposed to revert to completing another command. Think sudo another_command
style.
...
case $subcommand in
(exec)
_arguments -S -C \
'(-p --profile)'{-p,--profile}'[something]: :' \
'*::cmd:->cmd' && ret=0
case $state in
(cmd)
_normal -P
;;
esac
...
This behaves as follows:
command exec <tab>
- correct, completes new commandcommand exec -p foo <tab>
- completes new commandcommand exec -p foo -- <tab>
- correct, completes new commandcommand exec -- <tab>
- wrong, suggests local files
I'm confused what's different about the last case - I expected -S
to ignore --
like in the previous case. Why doesn't it? (the code does get to the _normal -P
line correctly in all cases, echo-debugging confirmed it)
_complete_help
at the wrong completion shows:
tags in context :completion::complete:--::
globbed-files (_files _default)
and at the right completion:
tags in context :completion::complete:-command-::
commands builtins functions aliases suffix-aliases reserved-words jobs parameters parameters (_command_names _autocd)
commands (_path_commands _command_names _autocd)
jobs (_jobs _command_names _autocd)
local-directories