mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-19 11:22:45 +08:00
Fix crash if $PWD is used as for-loop variable
for PWD in foo; true; end prints: >..src/parse_execution.cpp:461: end_execution_reason_t parse_execution_context_t::run_for_statement(const ast::for_header_t&, const ast::job_list_t&): Assertion `retval == ENV_OK' failed. because this used the wrong way to see if something is read-only.
This commit is contained in:
parent
55732f445a
commit
dd3cdbcfc9
|
@ -447,7 +447,7 @@ end_execution_reason_t parse_execution_context_t::run_for_statement(
|
|||
}
|
||||
|
||||
auto var = parser->vars().get(for_var_name, ENV_DEFAULT);
|
||||
if (var && var->read_only()) {
|
||||
if (env_var_t::flags_for(for_var_name.c_str()) & env_var_t::flag_read_only) {
|
||||
return report_error(STATUS_INVALID_ARGS, header.var_name,
|
||||
L"You cannot use read-only variable '%ls' in a for loop",
|
||||
for_var_name.c_str());
|
||||
|
|
|
@ -500,3 +500,11 @@ echo banana
|
|||
# This used to be a parse error - #7685.
|
||||
echo (echo hello\\)
|
||||
# CHECK: hello\
|
||||
|
||||
# Should fail because $PWD is read-only.
|
||||
for PWD in foo bar
|
||||
true
|
||||
end
|
||||
# CHECKERR: {{.*}}/basic.fish (line {{\d+}}): You cannot use read-only variable 'PWD' in a for loop
|
||||
# CHECKERR: for PWD in foo bar
|
||||
# CHECKERR: ^
|
||||
|
|
Loading…
Reference in New Issue
Block a user