diff --git a/src/builtin_argparse.cpp b/src/builtin_argparse.cpp index 3b38c0e0b..d1a9ec576 100644 --- a/src/builtin_argparse.cpp +++ b/src/builtin_argparse.cpp @@ -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; diff --git a/tests/argparse.err b/tests/argparse.err index 14120e58e..417c205a0 100644 --- a/tests/argparse.err +++ b/tests/argparse.err @@ -118,3 +118,6 @@ in function 'notargparse' #################### # Check for crash when last option is unknown + +#################### +# Checking arguments after -- diff --git a/tests/argparse.in b/tests/argparse.in index 3b9c0d811..01d9aba3b 100644 --- a/tests/argparse.in +++ b/tests/argparse.in @@ -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 diff --git a/tests/argparse.out b/tests/argparse.out index 2a1f9b8c7..c70257994 100644 --- a/tests/argparse.out +++ b/tests/argparse.out @@ -140,3 +140,9 @@ alpha aaaa #################### # Check for crash when last option is unknown + +#################### +# Checking arguments after -- +a +b +-a