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
{{ message }}
Repository navigation
[compat-gap] in-engine external_cat emulation silently ignores all options (-n/-A/-E lost, -Z not rejected) for bare cat and /bin/cat #415
$ printf'alpha\nbravo\ncharlie\n'> f.txt
$ rubash.exe -c 'cat -n f.txt'# no line numbers, rc 0alphabravocharlie
$ rubash.exe -c 'cat -n f.txt | cat'# correct — real cat.exe runs in the pipeline stage 1 alpha 2 bravo 3 charlie
$ rubash.exe -c 'cat -Z f.txt'# unknown option silently accepted, rc 0 (GNU: invalid option, rc 1)
GNU bash + coreutils cat numbers the lines in the first case. Control probes
on the same machine (sort -r, wc -l, grep -n, direct-to-console) all
keep their options — only cat is affected.
Owner
src/executor/external_file_builtins.rs — handle_external_file_builtins()
routes "cat" | "/bin/cat" | "/usr/bin/cat" to the in-engine external_cat()
(match arm at :84; enabled via external_file_builtins_enabled, init.rs:365). external_cat implements only the -v show-nonprinting family
(cat_has_show_nonprinting / cat_v_filter); -n, -A, -E, -b, -s, -t, -u, --number, --show-all, ... are silently dropped, and an unknown
option is not rejected. Piped stages bypass the emulation (real subprocess),
which is why the bug only shows when cat's output goes directly to the
shell's stdout/file redirection — the exact pattern niubash#152 characterized.
type -a cat reports /bin/cat (virtual namespace, path.rs unix_bin_basename), so every bare cat in scripts hits this path.
Fix direction
Either implement the coreutils cat option surface in external_cat
(numbering/show-nonprinting/squeeze/ends, -- handling, unknown-option
diagnostics with GNU wording cat: invalid option -- 'Z' rc 1), or narrow
the emulation's admission (e.g. plain concatenation only; any option word
falls through to the real PATH binary — a false negative there only costs
speed, per the admission-whitelist rule in AGENTS.md).
Cross-links
niubash#152 (user-visible report; comment has the attribution chain)
Landed as f74e37ac + streaming hotfix dca2e42: external_cat now implements GNU cat's full option surface in-process (parse_cat_argv with GNU's argv permutation and ambiguity ordering; cat_format numbering/-b-wins/$/-s squeeze across operands/-e -t -A compositions; GNU-exact usage diagnostics with possibilities column; --help/--version fall through to the real binary). 174/174 two-shell matrix vs WSL coreutils 9.4. The CI hotfix: the \x27-\x27 operand with identity options and the REAL process stdin streams per chunk (GNU cat.c byte-copy) instead of a buffered drain — the drain deadlocked coproc.tests' interactive coproc { cat - ; } shape (run-coproc exit 124); in-memory sources and formatting keep the bounded drain. Pinned hang test added (two-round write->read interleave). issue415 suite 15/15. niubash#152 closes with this.
Activity
fix(#415): external_cat implements the GNU coreutils cat option surface
fix(#415, CI hotfix): `cat -` streams real stdin per chunk (GNU cat.c…
caomengxuan666 commentedon Oct 2, 2026
Landed as f74e37ac + streaming hotfix dca2e42: external_cat now implements GNU cat's full option surface in-process (parse_cat_argv with GNU's argv permutation and ambiguity ordering; cat_format numbering/-b-wins/$/-s squeeze across operands/-e -t -A compositions; GNU-exact usage diagnostics with possibilities column; --help/--version fall through to the real binary). 174/174 two-shell matrix vs WSL coreutils 9.4. The CI hotfix: the \x27-\x27 operand with identity options and the REAL process stdin streams per chunk (GNU cat.c byte-copy) instead of a buffered drain — the drain deadlocked coproc.tests' interactive
coproc { cat - ; }shape (run-coproc exit 124); in-memory sources and formatting keep the bounded drain. Pinned hang test added (two-round write->read interleave). issue415 suite 15/15. niubash#152 closes with this.