mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-02 14:01:20 -03:00
Check if the for variable is invalid before trying to set it
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
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.
|
||||
wcstring_list_t arguments;
|
||||
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);
|
||||
|
||||
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);
|
||||
block_t *fb = parser->push_block(block_t::for_block());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user