Reject empty variable names

This allowed `set "" foo`, which is bogus and results in an unusable variable.
This commit is contained in:
Fabian Homborg
2021-03-14 20:03:56 +01:00
parent c2eef7c250
commit 02699d1acc
3 changed files with 24 additions and 4 deletions

View File

@@ -634,8 +634,9 @@ static int builtin_set_show(const wchar_t *cmd, const set_cmd_opts_t &opts, int
wchar_t *arg = argv[i];
if (!valid_var_name(arg)) {
streams.err.append_format(_(L"$%ls: invalid var name\n"), arg);
continue;
streams.err.append_format(BUILTIN_ERR_VARNAME, cmd, arg);
builtin_print_error_trailer(parser, streams.err, cmd);
return STATUS_INVALID_ARGS;
}
if (std::wcschr(arg, L'[')) {