Skip to content

fix(host): stdin-script (-s) reads on demand through the engine driver (rubash#586 host half) - #314

Merged
caomengxuan666 merged 2 commits into
masterfrom
fix/586-host-stdin-script
Oct 13, 2026
Merged

caomengxuan666 merged 2 commits into
masterfrom
fix/586-host-stdin-script

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Host-side follow-up to unixwin/rubash#593 (merged): niu -s used to slurp the whole stdin with read_to_string before handing one big string to execute_script — $(exec cat)/read/a top-level exec hit EOF immediately and the unconsumed tail came back as code (data-as-code, rc 127). rubash#593 moved the GNU-correct on-demand driver into the lib (input.c:381-397: a non-seekable stdin gets a 1-byte parser buffer); the host now calls rubash::script_driver::run_stdin_script(&mut shell.executor) instead of slurping.

Byte-verified against WSL GNU bash 5.3.0 on the issue repro:

printf 'echo one\nv=$(exec cat)\necho "v=[$v]"\nMARKER-DATA-1\nMARKER-DATA-2\n' | niu -s

Both print one, rc 0 — the marker lines are consumed as data and never execute.

Validation: RUSTFLAGS="-D warnings" cargo check -p niubash green, cargo fmt --check clean. Note for the release notes: this changes niu -s stdin consumption semantics to GNU (the on-demand shape), which is the contract fix, not a regression.

…r (rubash#586 host half)

niu -s used to slurp the whole stdin with read_to_string before handing
one big string to execute_script: $(exec cat)/read/top-level exec hit
EOF immediately and the unconsumed tail came back as code (data-as-code,
rc 127). rubash#593 moved the GNU-correct on-demand driver into the lib
(input.c:381-397 non-seekable 1-byte parser buffer); the host now calls
it instead of slurping.

Byte-verified against WSL GNU bash 5.3.0 on the issue repro
(printf 'echo one\nv=$(exec cat)\necho "v=[$v]"\nMARKER-DATA-1\nMARKER-DATA-2'
| niu -s): both print "one", rc 0, markers consumed as data.
@caomengxuan666
caomengxuan666 deleted the fix/586-host-stdin-script branch October 13, 2026 07:06
@caomengxuan666
caomengxuan666 merged commit 916afd3 into master Oct 13, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant