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
echo hi | { exec</dev/null; head -1;echo"rc=$?"; }
# GNU bash 5.3: (empty), rc=0 (head reads /dev/null)# niu: hi, rc=0 — the pipe is still stdin after exec
Also: exec < regular-file (bash reads FILEDATA, niu reads pipe), exec <&- (bash empty, niu pipe data), in { } groups, ( ) subshells, middle pipe positions. NOT affected (verified same): exec >f / exec 2>f / exec {fd}>f in pipe groups, all exec forms at top level or plain groups/subshells/functions, exec {r}<f + cat <&$r workaround, per-command < file / <<< / <&0. Medium: scripts re-pointing stdin mid-pipeline silently read stale pipe data with rc=0.
Env: niubash 1.4.4 / rubash engine (master ~2026-10), GNU bash 5.3.20 aarch64-linux-android as oracle.
Sibling nuance from builtin-pipe fast-path sweep (read/mapfile instead of head): echo hi | { exec 0<&-; read x; ...; } → bash read error: Bad file descriptor rc=1 / niu reads stale hi rc=0; exec 0</dev/null + mapfile → bash n=0 / niu n=1. BUT exec 0<regular-file + read matches on both (FILEDATA) — so the leak is specific to non-regular-file targets (null/closed) for read/mapfile, unlike head/cat which leak everything. Same root family, different boundary.
Verified fixed on master (a55e4d6) — fixed by b9fd97a 'fix(executor): exec-rebound fd 0 shadows the pipeline stage stdin buffer (#1102)'.
Repro against release build of current master:
$ echo hi | { exec </dev/null; head -1; echo "rc=$?"; }
rc=0
$ echo hi | { exec < in.txt; head -1; echo "rc2=$?"; }
FILEDATA
rc2=0
$ echo hi | { exec <&-; head -1; echo "rc3=$?"; }
rc3=0
The reported symptom is gone: the exec-installed stdin redirect is honored inside pipeline components — pipe data no longer leaks through (matches GNU for exec </dev/null and exec < file).
One residual note for a possible follow-up: for exec <&-, GNU head fails EBADF with rc=1 while rubash's head sees an empty stream (rc=0). The same divergence occurs at top level outside pipelines, so it is a general fd-0-closed fidelity edge, not the pipeline bug reported here.
Activity
caomengxuan666 commentedon Oct 22, 2026
Sibling nuance from builtin-pipe fast-path sweep (read/mapfile instead of head):
echo hi | { exec 0<&-; read x; ...; }→ bashread error: Bad file descriptorrc=1 / niu reads stalehirc=0;exec 0</dev/null+mapfile→ bash n=0 / niu n=1. BUTexec 0<regular-file+readmatches on both (FILEDATA) — so the leak is specific to non-regular-file targets (null/closed) for read/mapfile, unlike head/cat which leak everything. Same root family, different boundary.caomengxuan666 commentedon Oct 23, 2026
Verified fixed on master (a55e4d6) — fixed by b9fd97a 'fix(executor): exec-rebound fd 0 shadows the pipeline stage stdin buffer (#1102)'.
Repro against release build of current master:
The reported symptom is gone: the exec-installed stdin redirect is honored inside pipeline components — pipe data no longer leaks through (matches GNU for
exec </dev/nullandexec < file).One residual note for a possible follow-up: for
exec <&-, GNU head fails EBADF with rc=1 while rubash's head sees an empty stream (rc=0). The same divergence occurs at top level outside pipelines, so it is a general fd-0-closed fidelity edge, not the pipeline bug reported here.fix(executor): dup write-only fds onto `<&N` instead of failing the r…