function: Reject invalid variable names for --argument-names

Fixes #6147.
This commit is contained in:
Fabian Homborg
2019-10-07 21:21:38 +02:00
parent 422441e903
commit a7913c3a10
2 changed files with 18 additions and 0 deletions

View File

@@ -225,6 +225,10 @@ int builtin_function(parser_t &parser, io_streams_t &streams, const wcstring_lis
if (argc != optind) {
if (opts.named_arguments.size()) {
for (int i = optind; i < argc; i++) {
if (!valid_var_name(argv[i])) {
streams.err.append_format(BUILTIN_ERR_VARNAME, cmd, argv[i]);
return STATUS_INVALID_ARGS;
}
opts.named_arguments.push_back(argv[i]);
}
} else {