Skip to content

[cli][P1] -s stdin-script pre-buffers the whole stream: $(exec cat) hits EOF and unconsumed data lines execute as code (#583 -c/-s gap) #586

Closed

Description

@caomengxuan666

Repro: niu.exe -s < repro.sh where repro.sh = echo one / v=$(exec cat) / echo "v=[$v]" / MARKER-DATA-1 / MARKER-DATA-2.

  • GNU: prints one then eats the remaining 3 lines as data (v=[MARKER-DATA-1 MARKER-DATA-2]), rc 0
  • niu: one / v=[] / then MARKER-DATA-1 and MARKER-DATA-2 execute as commands (rc 127)
    Same for bare read -r l (EOF instead of the next script line) and top-level exec cat. -c + piped stdin is correct — the gap is the -s (stdin-script) entry reading the whole stream up front. Data-as-code: curl | bash -s shaped install scripts are a correctness AND safety hazard. Found by the 1.4.0 pre-release semantic sweep (rubash b5e1a2f).

Activity

  1. added
    bug
    on Oct 13, 2026
  2. caomengxuan666 commented on Oct 13, 2026

    @caomengxuan666
    MemberAuthor

    fixed by #593 — the -s stdin-script on-demand reader is now the canonical library driver (rubash::script_driver::run_stdin_script) with the GNU input.c stream-position contract documented at the definition and the full consumer matrix pinned in tests/issue586_stdin_script_on_demand_regressions.rs (comsub exec cat / plain cat / bare read / top-level exec cat / code-resume / seekable-file). Host -s routes must run this driver instead of pre-buffering stdin; the niu product follow-up is [email protected]:612-614 swapping its read_to_string slurp for this API. CI on #593 fully green.

  3. added 2 commits that reference this issue on Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions