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
invocation/diagnostics: -eu nounset rc, -- separator, niu -o with no arg, error-message branding #705
With -u alone both give 127; adding -e makes bash switch to 1 while niu stays 127. Same via set -eu in a script. The nounset fatal path does not account for errexit.
R7.2 -- separator is not bash-compatible
$ printf'echo X\n'| niu -- ;echo$?
niu : stderr "bash: --: option requires a script"; rc=2
bash: prints X, rc=0 (bash reads stdin)
$ niu -- nosuch.sh ;echo$?
niu : stderr "niu: 系统找不到指定的文件。 (os error 2)"; rc=1
bash: exit 127
$ niu nosuch.sh ;echo$?
niu : stderr "niu: nosuch.sh: No such file or directory"; rc=127 # the normal path is fine
Two defects: -- with no operand rejects stdin (bash reads it), and a missing script after -- exits 1 with a raw, localized OS error instead of the normal message + 127.
R7.3 niu -o with no argument errors instead of listing options
$ niu -o ;echo$?
niu : stderr "bash: -o: option requires an argument"; rc=2
bash: prints the full option list ; rc=0
R7.4 Error-message branding is inconsistent
Different failure paths identify the shell differently (exit codes/streams otherwise match bash):
command not found niu: line 1: nosuchcmd: command not found
syntax error niu: -c: line 1: syntax error ...
unbound variable niu: line 1: NOPE: unbound variable
exit too many arguments rubash: exit: too many arguments
invalid long option bash: --bogus: invalid option ...
invalid shell option bash: line 0: bogusopt: invalid shell option name
Program name (niu: / rubash: / bash:) and the presence of line N: vary by path. Cosmetic, but it defeats scripts/tests that key on the prefix.
Dependency note: three of the four items here live in src/invocation.rs, which is being rewritten by open PR #697 (fix/382-option-cluster, the clustered-option parser plus the generated SHORT_OPTIONS table). Working on R7.1 (-eu nounset rc), R7.2 (-- separator) or R7.4 (error-message branding) before that lands will conflict with it.
Suggested order: land #697, then rebase this work on it. R7.3 (niu -o with no argument) probably belongs with the same table, so it may be worth folding in rather than fixing separately.
Version note (correction to the Method line): the oracle was reached with bare wsl.exe -e bash, which resolves through PATH to /usr/local/bin/bash = GNU bash 5.3.0(1) — not 5.2.21. The 5.2.21 build lives at /bin/bash, and every item in this report was re-checked on it as well; results were identical on both.
So the two versions are listed in the wrong order above: 5.3.0 was the default, 5.2.21 the cross-check.
No finding here changes; noting it only so the numbers reproduce. (Incidentally 5.3.0 is also the oracle cited in rubash#641, "the repository oracle is WSL 5.3.0".)
Re-checked all four items on current master (7490feb0) against WSL GNU bash 5.3.0(1) and fixed the three unambiguous ones in #778:
R7.1 reproduced (127 vs GNU 1) and fixed in the executor: shell.c:1471 only remaps the nounset FORCE_EOF jump to 127 with errexit off; with -e, error.c:169 report_error exits via EXITPROG with 1 first. -u alone stays 127, -eu is 1.
R7.2 reproduced on the ShellInvocation route: -- with no operand now reads stdin and the lone - form now ends options too (shell.c:905-911). The engine's -- nosuch.sh route already prints the normal message + rc 127. Host follow-up (niubash repo, not #778):niu -- nosuch.sh exits 1 with the raw localized OS error because the launcher's run_shell_invocation script branch does std::fs::read_to_string(...)? instead of its normal missing-script handling (niu: <name>: No such file or directory, rc 127).
R7.3 reproduced on the ShellInvocation route; fixed: argument-less -o/+o is the list_minus_o_opts form (shell.c:931-938), now emitted during option application. (Adjacent, unreported: -O/+O with no argument still errors; GNU prints the shopt table rc 0.)
R7.4 — open, product-copy call. Not changed. GNU vs niu 1.4.0 vs engine, same exit codes/streams:
path
GNU bash 5.3.0
niu 1.4.0
engine
command not found
bash: line 1: nosuchcmd: command not found
niu: line 1: …
bash: line 1: …
syntax error
bash: -c: line 2: syntax error: unexpected end of file from \if' command on line 1`
niu: -c: line 2: …
byte-identical to GNU
unbound variable
bash: line 1: NOPE: unbound variable
niu: line 1: …
bash: line 1: …
exit: too many args
bash: line 1: exit: too many arguments
rubash: exit: too many arguments
rubash: exit: too many arguments
invalid long option
bash: --bogus: invalid option
bash: --bogus: invalid option
match
invalid shell option
bash: line 0: bash: bogusopt: invalid option name
bash: line 0: bogusopt: invalid shell option name
byte-identical to GNU
The decision is two entangled sub-questions: (1) should the engine's own diagnostics print the canonical bash: (the reporter's scripts/tests key on it) or follow the invocation face, when src/builtins/exit.rs:64 currently hardcodes rubash: while every other engine path prints bash:; and (2) the GNU line N: segment that exit: too many arguments drops (not branding, fixable once (1) is decided). The niu: rows are the launcher's own strings and live in the niubash repo.
Closed by b6ca9ea + 5f3fb55/eee1aa6 — all four R7 items done.
R7.1 / R7.2 / R7.3 — confirmed fixed earlier
R7.1 (-eu nounset rc), R7.2 (-- separator reads stdin, missing script after -- exits 127 with the normal message), R7.3 (-o with no operand lists options): all verified against the engine plus their pinned suites (tests/issue705_nounset_errexit_status.rs, issue705_dashdash_separator.rs, issue705_option_list.rs — green).
R7.4 — branding + the exit-error semantics behind it
The probe battery for this item surfaced something bigger than branding: bash 5.2 and 5.3 genuinely diverge on the exit error paths, and the repo baseline is 5.3.0 (architecture.md:55). Every case below was re-pinned against a locally built bash-5.3.0(1)-release binary (probe letters A-X/W/Y from the 2026-10-18 battery); earlier 5.2.21-based conclusions in this thread are superseded wherever they disagree.
exit 1 2 (too many arguments) is no_args(), a DISCARD — not a plain failure. GNU prints the reader-prolog diagnostic, puts 2 into $? (set_exit_status (EX_BADUSAGE)), then top_level_cleanup + jump_to_top_level (DISCARD): the rest of the current command list is abandoned with every parse_and_execute level popped. Script/stdin continue with the next command ($?=2); a -c string is abandoned whole and shell.c:1477's DISCARD catch exits 1. Implemented on the failglob abort scope: GNU abandons the rest of the line, niu only the failing command (one extra statement runs after the error) #753 evalerror vehicle behind a new evalerror_exit_toomany_pending class marker: eval'd/sourced strings unwind WHOLE (no line-contained skip — probe V2), the caller continues (W1/W6), subshells contain it (P6/S9), and ONLY this class triggers the -c stop — failglob/subscript keep their line-contained -c shape (probe G1).
exit abc keeps 5.3's continue-with-$?=2 shape (probe D: -c 'exit abc; echo AFTER' prints AFTER). 5.2 exited rc=2; rubash already matched 5.3, now pinned. get_exitstat checks the first word's numeric validity before no_args, so exit abc def reports the numeric error (Y7).
exit -- is skipped per ISOPTION(word, '-') — exit -- exits with $?, exit -- 1 exits 1, exit -- 1 2 is the too-many error (X4-X6); exit - stays the numeric error (X3). Previously rubash reported exit: --: numeric argument required for all three.
Prologs: too-many/numeric diagnostics carry the executor's diagnostic_prefix (bash: line N: under -c, <script>: line N: in scripts, the exit command's own body line inside functions — U3). The old builtin-level helper read __RUBASH_* through the process environment, which the engine never exports, so the line segment was silently dropped. That was the R7.4 holdout.
Usage errors exit 2 per GNU: enable -f missing operand and invalid option (enable.def:163 default arm, return (EX_USAGE)), cd a b (cd.def:329-330 return (EX_USAGE)). An earlier working-tree pass of this fix recorded cd too-many as rc 1 from a mis-read probe — the 5.3.0 source AND binary both say 2; corrected.
cd diagnostics survive exec 2>file / exec >file rebinds — the buffered-output flush falls back when the route reports no default endpoint, the contract external_redirects.rs already follows. Silent-drop bug found while probing the branding (both channels).
export's usage line gains the GNU [-f] tail (setattr.def:53).
Known residual micro-divergences (recorded, not fixed)
(exit 1 2): GNU leaves 2 behind a script-file subshell but 1 under -c (mode-dependent catch); rubash leaves 2 in both modes. $(exit 1 2): GNU leaves 1 in both modes; rubash leaves 1 under -c (fork copy) but 2 in script mode. Status value only — control flow matches everywhere.
The interactive / and logout faces of exit are untouched.
Tests
tests/issue705_error_branding.rs — 25 cases, ids 705.20+, each citing its 5.3.0 probe letter per the #746 method: 18 [ratchet] cases proven red on the pre-fix engine by revert-gate, plus [control]/[guard] cases for the numeric shapes, healthy exits, and the -- skip. 5f3fb55 (void; superseded by eee1aa6) / eee1aa6 additionally updated the executor_command_chaining assertions that keyed on the retired rubash: brand and the old exit 1 2 semantics, and fixed the out-of-bounds panic #789 shipped in mark_literal_ifs_chars.
Two regressions of the 2026-10-18 PR wave that surfaced during the combined-suite verification are filed separately as #795/#796.
Activity
caomengxuan666 commentedon Oct 17, 2026
Dependency note: three of the four items here live in
src/invocation.rs, which is being rewritten by open PR #697 (fix/382-option-cluster, the clustered-option parser plus the generatedSHORT_OPTIONStable). Working on R7.1 (-eunounset rc), R7.2 (--separator) or R7.4 (error-message branding) before that lands will conflict with it.Suggested order: land #697, then rebase this work on it. R7.3 (
niu -owith no argument) probably belongs with the same table, so it may be worth folding in rather than fixing separately.caomengxuan666 commentedon Oct 17, 2026
Version note (correction to the Method line): the oracle was reached with bare
wsl.exe -e bash, which resolves through PATH to/usr/local/bin/bash= GNU bash 5.3.0(1) — not 5.2.21. The 5.2.21 build lives at/bin/bash, and every item in this report was re-checked on it as well; results were identical on both.So the two versions are listed in the wrong order above: 5.3.0 was the default, 5.2.21 the cross-check.
No finding here changes; noting it only so the numbers reproduce. (Incidentally 5.3.0 is also the oracle cited in rubash#641, "the repository oracle is WSL 5.3.0".)
fix(read): count decoded units for read -n/-N carrier-pair limits (#714…
caomengxuan666 commentedon Oct 17, 2026
Re-checked all four items on current
master(7490feb0) against WSL GNU bash 5.3.0(1) and fixed the three unambiguous ones in #778:R7.1 reproduced (127 vs GNU 1) and fixed in the executor: shell.c:1471 only remaps the nounset
FORCE_EOFjump to 127 with errexit off; with-e, error.c:169report_errorexits viaEXITPROGwith 1 first.-ualone stays 127,-euis 1.R7.2 reproduced on the
ShellInvocationroute:--with no operand now reads stdin and the lone-form now ends options too (shell.c:905-911). The engine's-- nosuch.shroute already prints the normal message + rc 127. Host follow-up (niubash repo, not#778):niu -- nosuch.shexits 1 with the raw localized OS error because the launcher'srun_shell_invocationscript branch doesstd::fs::read_to_string(...)?instead of its normal missing-script handling (niu: <name>: No such file or directory, rc 127).R7.3 reproduced on the
ShellInvocationroute; fixed: argument-less-o/+ois thelist_minus_o_optsform (shell.c:931-938), now emitted during option application. (Adjacent, unreported:-O/+Owith no argument still errors; GNU prints the shopt table rc 0.)R7.4 — open, product-copy call. Not changed. GNU vs
niu1.4.0 vs engine, same exit codes/streams:bash: line 1: nosuchcmd: command not foundniu: line 1: …bash: line 1: …bash: -c: line 2: syntax error: unexpected end of file from \if' command on line 1`niu: -c: line 2: …bash: line 1: NOPE: unbound variableniu: line 1: …bash: line 1: …bash: line 1: exit: too many argumentsrubash: exit: too many argumentsrubash: exit: too many argumentsbash: --bogus: invalid optionbash: --bogus: invalid optionbash: line 0: bash: bogusopt: invalid option namebash: line 0: bogusopt: invalid shell option nameThe decision is two entangled sub-questions: (1) should the engine's own diagnostics print the canonical
bash:(the reporter's scripts/tests key on it) or follow the invocation face, whensrc/builtins/exit.rs:64currently hardcodesrubash:while every other engine path printsbash:; and (2) the GNUline N:segment thatexit: too many argumentsdrops (not branding, fixable once (1) is decided). Theniu:rows are the launcher's own strings and live in the niubash repo.fix(invocation): #705 R7.1-R7.3 (errexit nounset rc, `--`, argument-l…
fix(executor): exit errors follow bash 5.3, and usage errors exit 2 (#…
fix: update errors.snap for #705 (exit usage errors now exit 2 per ba…
fix(executor): clamp the #743 IFS-marker braced skip; update 5.3-sema…
fix(executor): clamp the #743 IFS-marker braced skip; update 5.3-sema…
caomengxuan666 commentedon Oct 18, 2026
Closed by b6ca9ea + 5f3fb55/eee1aa6 — all four R7 items done.
R7.1 / R7.2 / R7.3 — confirmed fixed earlier
R7.1 (
-eunounset rc), R7.2 (--separator reads stdin, missing script after--exits 127 with the normal message), R7.3 (-owith no operand lists options): all verified against the engine plus their pinned suites (tests/issue705_nounset_errexit_status.rs,issue705_dashdash_separator.rs,issue705_option_list.rs— green).R7.4 — branding + the exit-error semantics behind it
The probe battery for this item surfaced something bigger than branding: bash 5.2 and 5.3 genuinely diverge on the
exiterror paths, and the repo baseline is 5.3.0 (architecture.md:55). Every case below was re-pinned against a locally built bash-5.3.0(1)-release binary (probe letters A-X/W/Y from the 2026-10-18 battery); earlier 5.2.21-based conclusions in this thread are superseded wherever they disagree.Fixed in b6ca9ea:
exit 1 2(too many arguments) isno_args(), a DISCARD — not a plain failure. GNU prints the reader-prolog diagnostic, puts 2 into $? (set_exit_status (EX_BADUSAGE)), thentop_level_cleanup+jump_to_top_level (DISCARD): the rest of the current command list is abandoned with every parse_and_execute level popped. Script/stdin continue with the next command ($?=2); a-cstring is abandoned whole and shell.c:1477's DISCARD catch exits 1. Implemented on the failglob abort scope: GNU abandons the rest of the line, niu only the failing command (one extra statement runs after the error) #753 evalerror vehicle behind a newevalerror_exit_toomany_pendingclass marker: eval'd/sourced strings unwind WHOLE (no line-contained skip — probe V2), the caller continues (W1/W6), subshells contain it (P6/S9), and ONLY this class triggers the-cstop — failglob/subscript keep their line-contained-cshape (probe G1).exit abckeeps 5.3's continue-with-$?=2 shape (probe D:-c 'exit abc; echo AFTER'prints AFTER). 5.2 exited rc=2; rubash already matched 5.3, now pinned.get_exitstatchecks the first word's numeric validity beforeno_args, soexit abc defreports the numeric error (Y7).exit --is skipped perISOPTION(word, '-')—exit --exits with $?,exit -- 1exits 1,exit -- 1 2is the too-many error (X4-X6);exit -stays the numeric error (X3). Previously rubash reportedexit: --: numeric argument requiredfor all three.Prologs: too-many/numeric diagnostics carry the executor's
diagnostic_prefix(bash: line N:under -c,<script>: line N:in scripts, the exit command's own body line inside functions — U3). The old builtin-level helper read__RUBASH_*through the process environment, which the engine never exports, so the line segment was silently dropped. That was the R7.4 holdout.Usage errors exit 2 per GNU:
enable -fmissing operand and invalid option (enable.def:163 default arm,return (EX_USAGE)),cd a b(cd.def:329-330return (EX_USAGE)). An earlier working-tree pass of this fix recorded cd too-many as rc 1 from a mis-read probe — the 5.3.0 source AND binary both say 2; corrected.cd diagnostics survive
exec 2>file/exec >filerebinds — the buffered-output flush falls back when the route reports no default endpoint, the contract external_redirects.rs already follows. Silent-drop bug found while probing the branding (both channels).export's usage line gains the GNU
[-f]tail (setattr.def:53).Known residual micro-divergences (recorded, not fixed)
(exit 1 2): GNU leaves 2 behind a script-file subshell but 1 under-c(mode-dependent catch); rubash leaves 2 in both modes.$(exit 1 2): GNU leaves 1 in both modes; rubash leaves 1 under-c(fork copy) but 2 in script mode. Status value only — control flow matches everywhere./andlogoutfaces ofexitare untouched.Tests
tests/issue705_error_branding.rs— 25 cases, ids705.20+, each citing its 5.3.0 probe letter per the #746 method: 18 [ratchet] cases proven red on the pre-fix engine by revert-gate, plus [control]/[guard] cases for the numeric shapes, healthy exits, and the--skip. 5f3fb55 (void; superseded by eee1aa6) / eee1aa6 additionally updated the executor_command_chaining assertions that keyed on the retiredrubash:brand and the oldexit 1 2semantics, and fixed the out-of-bounds panic #789 shipped inmark_literal_ifs_chars.Two regressions of the 2026-10-18 PR wave that surfaced during the combined-suite verification are filed separately as #795/#796.
test(regression): #803 re-record the CRLF-pinned snapshots (nquote, c…