You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Programs that don't have sub-commands can accept any number of arguments.
However, when doing shell completion for such programs, within the __complete code this very __complete command makes it that the program suddenly has a sub-command, and the call to Find() -> legacyArgs() will then return an error if there are more than one argument on the command-line being completed.
This only happens when the program does not specify any value for its Args field, case which leads to legacyArgs() being called.
Here is an illustration. The program used follows.
# prog has no sub-commands
bash-5.1$ ./prog -h
Usage:
prog [flags]
Flags:
-h, --help help for prog
# prog has a ValidArgsFunction to complete arguments
bash-5.1$ ./prog __complete ''
arg1
arg2
:4
Completion ended with directive: ShellCompDirectiveNoFileComp
# Completion fails to continue completing arguments
bash-5.1$ ./prog __complete arg1 ''
[Debug] [Error] Unable to find a command for arguments: [arg1]
:0
Completion ended with directive: ShellCompDirectiveDefault
Fixesspf13#1562
Programs that don't have sub-commands can accept any number of args.
However, when doing shell completion for such programs, within the
__complete code this very __complete command makes it that the program
suddenly has a sub-command, and the call to Find() -> legacyArgs() will
then return an error if there are more than one argument on the
command-line being completed.
To avoid this, we first remove the __complete command in such a case so
as to get back to having no sub-commands.
Signed-off-by: Marc Khouzam <[email protected]>
Fixes#1562
Programs that don't have sub-commands can accept any number of args.
However, when doing shell completion for such programs, within the
__complete code this very __complete command makes it that the program
suddenly has a sub-command, and the call to Find() -> legacyArgs() will
then return an error if there are more than one argument on the
command-line being completed.
To avoid this, we first remove the __complete command in such a case so
as to get back to having no sub-commands.
Signed-off-by: Marc Khouzam <[email protected]>
Programs that don't have sub-commands can accept any number of arguments.
However, when doing shell completion for such programs, within the
__complete
code this very__complete
command makes it that the program suddenly has a sub-command, and the call toFind() -> legacyArgs()
will then return an error if there are more than one argument on the command-line being completed.This only happens when the program does not specify any value for its
Args
field, case which leads tolegacyArgs()
being called.Here is an illustration. The program used follows.
Test program
The text was updated successfully, but these errors were encountered: