mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-31 23:28:45 +00:00
Check if the for variable is invalid before trying to set it
This commit is contained in:
parent
e84dad5432
commit
d9f094db1a
1 changed files with 5 additions and 5 deletions
|
@ -438,6 +438,11 @@ end_execution_reason_t parse_execution_context_t::run_for_statement(
|
||||||
FAILED_EXPANSION_VARIABLE_NAME_ERR_MSG, for_var_name.c_str());
|
FAILED_EXPANSION_VARIABLE_NAME_ERR_MSG, for_var_name.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!valid_var_name(for_var_name)) {
|
||||||
|
return report_error(STATUS_INVALID_ARGS, header.var_name, BUILTIN_ERR_VARNAME, L"for",
|
||||||
|
for_var_name.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
// Get the contents to iterate over.
|
// Get the contents to iterate over.
|
||||||
wcstring_list_t arguments;
|
wcstring_list_t arguments;
|
||||||
ast_args_list_t arg_nodes = get_argument_nodes(header.args);
|
ast_args_list_t arg_nodes = get_argument_nodes(header.args);
|
||||||
|
@ -460,11 +465,6 @@ end_execution_reason_t parse_execution_context_t::run_for_statement(
|
||||||
}
|
}
|
||||||
assert(retval == ENV_OK);
|
assert(retval == ENV_OK);
|
||||||
|
|
||||||
if (!valid_var_name(for_var_name)) {
|
|
||||||
return report_error(STATUS_INVALID_ARGS, header.var_name, BUILTIN_ERR_VARNAME, L"for",
|
|
||||||
for_var_name.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
trace_if_enabled(*parser, L"for", arguments);
|
trace_if_enabled(*parser, L"for", arguments);
|
||||||
block_t *fb = parser->push_block(block_t::for_block());
|
block_t *fb = parser->push_block(block_t::for_block());
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue