Repository navigation
feat: set $SHELL to /bin/sh - #283
Open
ferdingler wants to merge 1 commit into
Open
ferdingler wants to merge 1 commit into
ferdingler wants to merge 1 commit into
Conversation
The initial environment now has SHELL=/bin/sh, which runs this shell inside the sandbox. A value the embedder sets for SHELL still wins. Part of strands-agents#207
Collaborator
Author
|
@strandly-the-agent Please review this PR |
9 of 10 tasks
strandly-the-agent
approved these changes
Nov 13, 2026
strandly-the-agent
left a comment
Collaborator
There was a problem hiding this comment.
Approve. I found nothing to block on or fix. SHELL=/bin/sh is set in the default env, builder and config-file values still win, and /bin/sh resolves to this shell.
@ferdingler one small optional tweak: builder_env_overrides_shell_var also passes with the vfs_kernel.rs line removed, so it only guards the override order. Keeping it is fine.
✅ What I verified (head 657d4d4)
- Override order.
new_process()sets the defaults first (src/vfs_kernel.rs:292).build()then applies the builder env withproc.set_env(src/shell.rs:1189,:1210-1211). Config[env]goes into the same list and skips keys.env()already set (src/shell.rs:1072-1074). I checked this from the CLI:--configwith[env] SHELL="/bin/lash"gives/bin/lash, and"$SHELL" -c 'echo $0'printslash. The Python and JS bindings both go throughbuilder.env. - Resolution.
/bin/sh -> lashis created on every build (src/vfs.rs:812)."$SHELL" -cworks, including afterPATH=/nowhere, and so doexec "$SHELL" -c,"$SHELL" script.sh, subshells and$( ). The MCP session (src/mcp.rs:387) also getsSHELL, because it uses the samenew_process(). - Tests. With the line removed,
shell_var_runs_this_shellfails (left: ""), so it really tests the change. - Docs and bindings. No README, AGENTS.md, Python or TS test lists the full default env.
env_listusescontains, and Python'scfg.env == {}still holds. - Runs.
cargo test --lib --bins: 72 passed.cargo test --test shell_integration: 1965 passed, 0 failed.
Appendix: non-blocking, older problems this PR makes easier to hit (2)
"$SHELL" -lc '…'fails with exit 126 andno such file or directory: /home/lash/-lc. Combined flags aren't parsed, and-lcis a common way tools start "the user's shell". This comes from oldershcode, not this PR, and open PR #270 already handles it. Not filed.echo 'echo in' | "$SHELL"prints nothing and exits 0, so a script piped to bareshis silently ignored. Also from older code. I didn't file it because #224 covered stdin forsh script, and I haven't checked whether bareshwas intentionally left out.
Collaborator
Author
|
Thanks. Keeping the override test as is: it's there to guard that an embedder's SHELL wins over the default, and the other test covers the default itself. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
$SHELLwasn't set, so anything that starts "the user's shell" with$SHELL -c ...ended up running an empty command name and failing. Plenty of tools and agent-written scripts do that.Now the starting environment has
SHELL=/bin/sh, the same pathcommand -v shgives and one that runs this shell inside the sandbox. If the embedder setsSHELLthemselves, through the builder or the config file, their value is kept. A custom kernel that builds its own environment isn't affected.I checked that
SHELL=/bin/shshows up inenv, that"$SHELL" -cruns a command, and that a value set through the builder wins over the default. The full Rust check passes.Related Issues
Part of #207
Documentation PR
None
Type of Change
New feature
Testing
How have you tested the change? Verify that the changes do not break functionality or introduce new warnings.
cargo test --workspace --all-targets,pytest tests/python,npm test)cargo fmtandcargo clippyChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.