Repository navigation
test(interactive): pin (A;B);) stray-close family to GNU 5.3.0 across all modes (#845) - #852
Merged
Merged
Conversation
… all modes (#845) #845 claimed GNU accepts the (A;B);) tail in an interactive PS2 continuation while rubash errors, interactive-only, with rubash -c and stdin script accepting the same shape. Measured against the sole baseline (WSL GNU Bash 5.3.0, /usr/local/bin/bash), the premise is false on every leg, so this lands the measured conformance as regressions instead of an engine change. Oracle falsification: the '#426 GNU 5.3 msys oracle' binary (winuxcmd/usr/bin/bash.exe, version string x86_64-pc-msys) is a 243 KB launcher whose embedded strings read 'bash shim: cannot locate niu.exe; set NIU_SHELL to its path' - it runs NIUBASH, so its 'accepts' verdict was niubash's own -c/stdin behavior echoed back. GNU truth (all live-verified, plus the grammar): simple_list: simple_list1 ';' (parse.y:1377-1394) reduces only when the lookahead is a terminator (simple_list_terminator parse.y:1310-1314); ')' cannot start simple_list1 (parse.y:1389), so ';' + ')' is a syntax error and the subshell never runs. - bash -c '(echo one; echo two);)' -> 'bash: -c: line 1: syntax error near unexpected token ')'', rc 2, nothing runs; multiline -c payload attributes the error to line 2. - stdin script one-liner -> 'line 1: syntax error ...', rc 2, shell exits before the next command (script mode dies on first parse error; verified 'echo a\n)\necho b' runs only 'echo a'). - stdin script '(echo one;\necho two);\n)' -> the ';'+NEWLINE completes the list, the subshell RUNS, then the stray ')' line is 'line 3: syntax error ...', rc 2, AFTER-OK never reached. - interactive -i -> diagnostic reported, nothing executes, session survives (eval.c:203-207 reader_loop: EOF_Reached only if interactive == 0); split after ');' the subshell runs at the PS2 boundary (read_secondary_line parse.y:2327) and the stray ')' errors separately. Verified for GNU on a real PTY (script -qec bash -i) and for rubash on a real ConPTY (pywinpty keystroke driver). The genuine divergence in this family lives in niubash (niu -c and stdin script accept the form, exit 0, where GNU rejects); niubash's tests/interactive.rs continuation_subshell_paren_completes comment needs the same oracle correction.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
结论先行
#845 的前提不成立:rubash 与真 GNU bash 5.3.0 在该形上无任何分歧。本 PR 不改引擎,只落实测一致性回归(6 条,覆盖
-c/ stdin 脚本 / 交互-i三路),把该族行为钉死。Oracle 证伪(根因证据)
#426 CR NIT-3 引用的「GNU bash 5.3 (msys) oracle」二进制
winuxcmd/usr/bin/bash.exe(版本串GNU bash, version 5.3.0(1)-release (x86_64-pc-msys))不是 bash,是一个 243 KB 的启动器 shim。二进制内嵌字符串:它实际拉起的是 niubash(niu.exe)。所谓「GNU 容忍
);)尾部(跑子壳体、exit 0)」的裁决是 niu 自己的行为被 shim 原样回显。以唯一基线 WSL GNU Bash 5.3.0(/usr/local/bin/bash) 实测,GNU 在全部四种形态(
-c/ 脚本 / 管道-i/ 真 PTY-i,后者经script -qec bash -i)都拒绝该形:syntax error near unexpected token ')',子壳体不执行。GNU C source 裁定
simple_list: simple_list1 ';'(parse.y:1377-1394)仅在 lookahead ∈simple_list_terminator = '\n' | yacc_EOF(parse.y:1310-1314)时归约;)不能开simple_list1(parse.y:1389)→;后遇)是 yyerror,子壳体不跑。;+NEWLINE 完成列表(list0,parse.y:1274-1286)→ 拆行在);之后的形态会执行子壳体,游离)单独报错。EOF_Reached仅if (interactive == 0));PS2:read_secondary_line(parse.y:2327)。实测矩阵(GNU=WSL 5.3.0;rubash ConPTY 走 pywinpty 键级驱动)
-c '(echo a; echo b);)'-c: line 1: syntax error near unexpected token ')',rc 2,不执行-c '(echo a;\necho b);)'-c: line 2: ...,rc 2(a; b);)line 1: ...,rc 2,后续命令不达(a;\nb);\n);+换行完成列表→跑 a,b;游离)行line 3: ...,rc 2-i(a;\nb);)),不执行,会话存活-i(a;\nb);\n))报错,存活-iecho a; )-i)诊断文本、行号归属、退出码逐字节一致(
-c行归属 line 1/line 2、脚本$0: line N:等)。变更内容
tests/issue845_subshell_stray_close_regressions.rs:6 条回归,逐条在 doc comment 引用 parse.y/eval.c 依据与 oracle 实跑记录。验证三行
cargo test --test issue845_subshell_stray_close_regressions;全量cargo test --no-fail-fast -- --test-threads=1中同样 6/6。cargo fmt --check干净;RUSTFLAGS="-D warnings" cargo check --all-targets仅既有 master 文件报错(issue592:249 / issue528:40 / issue282_stty / issue566),新文件零告警。niubash 侧跟进(另行安排,不在本仓)
niu -c与 niu stdin 脚本对(A;B);)接受(跑子壳体、exit 0),GNU 拒绝;niu 交互路径已与 GNU 一致。tests/interactive.rs::continuation_subshell_paren_completes(master:121,未被 ignore,已钉干净)收口):保留该腿;其注释(master:114-119)的「GNU 5.3 msys 容忍尾部」表述即本次证伪的 mis-oracle,需按上文更正;并建议补两条按 GNU 期望的腿——交互(printf a;PS2printf b);)应报语法错且不产出子壳体输出、随后提示符恢复;-c/stdin 腿应 rc 2。Closes #845(not-a-bug,前提被基线证伪;一致性由本 PR 回归钉住)。