mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-30 13:19:47 +00:00
Shell: Make for/match/functions put their variables only in the new scope
Otherwise, a function would, for example, overwrite its parent scope:
```sh
foo(x) { }
x=1
foo 2 # would make x=2 otherwise
```
This commit is contained in:
committed by
Andreas Kling
parent
97c5a78d27
commit
9bd81f34a5
@@ -479,7 +479,7 @@ bool Shell::invoke_function(const AST::Command& command, int& retval)
|
||||
size_t index = 0;
|
||||
for (auto& arg : function.arguments) {
|
||||
++index;
|
||||
set_local_variable(arg, adopt(*new AST::StringValue(command.argv[index])));
|
||||
set_local_variable(arg, adopt(*new AST::StringValue(command.argv[index])), true);
|
||||
}
|
||||
|
||||
auto argv = command.argv;
|
||||
|
||||
Reference in New Issue
Block a user