Repository navigation
fix(shell): match bash on head -c, exec redirects, and read -d - #442
Closed
fengqiaoqu wants to merge 1 commit into
Closed
fengqiaoqu wants to merge 1 commit into
fengqiaoqu wants to merge 1 commit into
Conversation
head -c left leftover stdin dropped, exec with no command ignored redirects, and read did not implement -d. Restore the remaining input after head, apply exec redirects to the shell, and treat an empty -d delimiter as NUL. Fixes strands-agents#440
Collaborator
|
Thanks for digging into these! Box no longer vendors Shell since #414, it depends on upstream strands-agents/shell, so this has nowhere to land here anymore. I checked upstream and all three gaps are still there ( |
10 tasks done
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
Since #397, stdin reaches the hosted Shell, and three behaviours still differ from bash.
x=$(head -c 1); catdropped the rest of stdin.headtakes fd 0 out of the process and did not put the remaining reader back, so leftover bytes were discarded with it. After aheadthat read stdin, fd 0 is restored.exec < /dev/nullwith no command returned 0 and left stdin unchanged (there was a TODO for this). Those redirects are now applied to the current shell, so later commands see them.read -d ''did not parse-d. An empty delimiter is NUL, as in bash: the builtin reads until that byte or EOF, assigns what it read, trims trailing IFS, and returns 1 when EOF arrives before the delimiter.The three cases in #440 are covered by tests in
crates/shell/tests/shell_integration.rs. The local shell divergence is recorded incrates/shell/UPSTREAM.md.Related Issues
Fixes #440
Type of Change
Bug fix
Testing
cargo test -p strands-shell --all-features: lib, integration (1345 passed), and doctests)cargo fmt --allandjust clippy(the workspace recipe, including the vendored-shell lint allowances)Not run: full workspace
just test.Checklist