argparse: Fix -- regression

I was a tad overzealous there with not appending the remaining
arguments.

Weird that we didn't test it, though.

Fixes #5857.
This commit is contained in:
Fabian Homborg 2019-05-03 16:20:40 +02:00
parent 411b4aea9d
commit e91eb85949
4 changed files with 17 additions and 4 deletions

View file

@ -634,10 +634,8 @@ static int argparse_parse_args(argparse_cmd_opts_t &opts, const wcstring_list_t
retval = check_for_mutually_exclusive_flags(opts, streams);
if (retval != STATUS_CMD_OK) return retval;
if (opts.stop_nonopt) {
for (int i = optind; argv[i]; i++) {
opts.argv.push_back(argv[i]);
}
for (int i = optind; argv[i]; i++) {
opts.argv.push_back(argv[i]);
}
return STATUS_CMD_OK;

View file

@ -118,3 +118,6 @@ in function 'notargparse'
####################
# Check for crash when last option is unknown
####################
# Checking arguments after --

View file

@ -189,3 +189,9 @@ echo $_flag_a
logmsg Check for crash when last option is unknown
argparse -i b/break -- "-b kubectl get pods -l name=foo"
begin
logmsg Checking arguments after "--"
argparse a/alpha -- a --alpha -- b -a
printf '%s\n' $argv
end

View file

@ -140,3 +140,9 @@ alpha aaaa
####################
# Check for crash when last option is unknown
####################
# Checking arguments after --
a
b
-a