Description
Subshells ( ... ) should provide full isolation — changes to functions, working directory, traps, and positional parameters should not leak to the parent shell. Currently, several of these leak.
Scope
- Function definitions leak: Functions defined in
( f() {...}; f ) are visible after the subshell
- cd leaks:
( cd /tmp ) changes the parent's working directory (VFS model issue)
- Traps leak:
( trap 'echo child' EXIT ) affects the parent
- Positional params leak:
( set -- x y ) modifies parent's $@
Repro
# Function isolation
( f() { echo inside; }; f )
f 2>/dev/null; echo $?
# bashkit outputs: inside\ninside\n0 (f leaks to parent)
# expected: inside\n127 (f not found in parent)
# Positional params
set -- a b c
( set -- x y; echo "$@" )
echo "$@"
# bashkit outputs: (empty)\n(empty) (params broken)
# expected: x y\na b c
Test coverage
4 skipped tests in crates/bashkit/tests/spec_cases/bash/subshell.test.sh (PR #351).
Oils reference: https://github.com/oilshell/oil/blob/master/spec/subshell.test.sh
Related
- This is expected behavior in bashkit's stateless interpreter model — subshells are not true forks
Description
Subshells
( ... )should provide full isolation — changes to functions, working directory, traps, and positional parameters should not leak to the parent shell. Currently, several of these leak.Scope
( f() {...}; f )are visible after the subshell( cd /tmp )changes the parent's working directory (VFS model issue)( trap 'echo child' EXIT )affects the parent( set -- x y )modifies parent's$@Repro
Test coverage
4 skipped tests in
crates/bashkit/tests/spec_cases/bash/subshell.test.sh(PR #351).Oils reference: https://github.com/oilshell/oil/blob/master/spec/subshell.test.sh
Related