mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:18:11 +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:
parent
97c5a78d27
commit
9bd81f34a5
3 changed files with 9 additions and 4 deletions
|
@ -34,3 +34,8 @@ fn() {
|
|||
fn2() { }
|
||||
|
||||
test "$(fn foobar)" = "foobar" || echo 'Frames are somehow messed up in nested functions' && exit 1
|
||||
|
||||
fn(xfoo) { }
|
||||
xfoo=1
|
||||
fn 2
|
||||
test $xfoo -eq 1 || echo 'Functions overwrite parent scopes' && exit 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue