You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] sh script / sh -c child shells inherit the parent's set -e / -u / -x #250
I have updated to the latest minor and patch version of Strands Shell (built from main)
I have checked the documentation and this is not expected behavior
I have searched issues and there are no duplicates
Binding
Rust
Strands Shell Version
main @ a064834 (also reproduced on PR #212 head caa0801)
Language Runtime Version
Rust 1.99.1
Operating System
Amazon Linux 2023 (aarch64)
Installation Method
built from source
Steps to Reproduce
printf'false\necho reached\n'> /tmp/e.sh
set -e; sh /tmp/e.sh;echo"parent $?"
Same with sh -c once #212 lands: set -e; sh -c 'false; echo reached'; echo "parent $?", or set -u; sh -c 'echo ${UNSET}x'.
Expected Behavior
A child sh starts with default options, as in bash/dash: prints reached then parent 0.
Actual Behavior
Prints nothing; the child aborts on false and the parent set -e then exits too. set -u makes the child fail with parameter not set (status 2).
Additional Context
The child is built with child.fork(), which copies opt_errexit / opt_nounset / opt_xtrace (src/os.rs:448-450), and run_pipeline doesn't reset them for sh/lash (src/exec.rsis_script branch). That's probably a few-line fix next to where #212 sets state_proc.arg0. The same fork also makes the parent's unexported variables, functions, and aliases visible to the child, which bash doesn't do. That's lower priority but has the same cause.
Possible Solution
Reset the opt_* flags on state_proc for sh/lash children (and optionally drop unexported vars/functions/aliases).
Activity
test: cover parent and function stages keeping their options (strands…