Repository navigation
Closed
Labels
Description
[Bug 批量·第六轮] bash 官方 83 tests 差分: PASS 仅 14/83, 37 项可靠差异 —— 官方测试与 GNU Bash 实际输出的一致性差距
背景与发现方法
直接以 GNU bash 源码自带的官方测试(third_party/bash/tests/*.tests,83 个文件,run-test 架构的测试本体)为输入做差分:每个 .tests 分别在 GNU Bash(Git Bash 5.2)与 winuxsh 0.10.2 下运行,逐字节对比 stdout + 退出码。.sub 子文件调用的 ./bash 在两侧分别指向各自 runner(公平对比)。
结果:PASS=14 / DIFF=69(共 83)——83% 的 bash 官方测试存在差异。
与既有「86 测试全过」的关系(重要澄清):winuxsh 仓库的 run-bash-upstream-with-winuxsh.sh 跑的是 run-*.sh 驱动器(对比 .right 期望文件,86 个通过)。本差分对比的是 bash 实际输出(不是 .right 期望)——结论是:winuxsh 输出匹配 .right 旧版期望,但不匹配 Git Bash 5.2 的实际输出(.right 是较老 bash 时代的期望,部分用例 Git Bash 5.2 自身输出就已不同于 .right)。这解释了两种结论并存。
可靠差异(37 项,bash 侧 rc=0 正常完成、输出/rc 与 winuxsh 不同)
全部为 rc bash=0 win=0 但 stdout 不同(个别 rc 不同),按主题分组:
1. 命令替换家族(comsub-eof / comsub-posix / comsub / dstack / dynvar)
- heredoc 边界(comsub-eof:
warning: here-document at line 1 delimited by end-of-file差异)、POSIX 模式命令替换、深层栈(dstack/dstack2)、动态变量(dynvar)
2. 引号/分词家族(nquote / nquote5 / ifs / quotearray / rhs-exp)
- 引号嵌套展开、IFS 分词(与 [Bug 批量·第二轮] 花括号展开/IFS 分词/glob 路径分隔符/BASHPID/进程替换/coproc 挂起/wait 错误/特殊内建管道扩展 - 11 项新差异(全部经 GNU Bash 对照) #21/[Bug 批量·第五轮] 全量清单聚焦: umask/trap/kill/set/echo/cd 内置族/sh-options/word-split/var-op/nameref/mksh 进制字面量 - oil 684+mksh 436 项 #24 家族互证)、
"${a[@]}"数组引号展开(quotearray)、RHS 展开(rhs-exp)
3. glob 家族(glob / globstar / extglob)
- 路径展开、
**globstar、extglob 匹配(与 [Bug 批量·第四轮] 三套件差分: oil spec 补全(427+ DIFF)/mksh check.t(153+ DIFF)/ksh93 tests - alias/数组/算术/heredoc/eglob/expand/错误码(后台全量继续中) #23 §1.3 家族互证)
4. 选项/错误语义(set-e / set-x / test / posixpipe)
set -e语义([Bug 批量] 命令替换状态污染 / heredoc / case 模式 / 参数替换 / 路径转换 / 重定向 / 调试钩子 - 20+ 个与 GNU Bash 的兼容性差异(含最小复现) #20 §3.2 家族)、xtrace 输出(set -x,与 [Bug 批量] 命令替换状态污染 / heredoc / case 模式 / 参数替换 / 路径转换 / 重定向 / 调试钩子 - 20+ 个与 GNU Bash 的兼容性差异(含最小复现) #20 §6 PS4 相关)、test内置、POSIX 管道
5. 其他(appendop / assoc / attr / braces / case / cond / coproc / dbg-support / exp / func / getopts / heredoc / history / intl / invocation / mapfile / rsh / tilde2 / varenv / vredir)
- 关联数组(assoc)、属性(attr)、花括号(braces)、case 模式、
[[ ]](cond)、coproc([Bug 批量·第二轮] 花括号展开/IFS 分词/glob 路径分隔符/BASHPID/进程替换/coproc 挂起/wait 错误/特殊内建管道扩展 - 11 项新差异(全部经 GNU Bash 对照) #21 §2.1 家族)、调试钩子(dbg-support)、getopts、heredoc([Bug 批量] 命令替换状态污染 / heredoc / case 模式 / 参数替换 / 路径转换 / 重定向 / 调试钩子 - 20+ 个与 GNU Bash 的兼容性差异(含最小复现) #20 §2.1 家族)、历史(history)、mapfile、~展开(tilde2)、环境变量(varenv)、重定向(vredir,[Bug 批量] 命令替换状态污染 / heredoc / case 模式 / 参数替换 / 路径转换 / 重定向 / 调试钩子 - 20+ 个与 GNU Bash 的兼容性差异(含最小复现) #20 §5.1 家族)等
其余 32 项(bash 侧 rc 非零,不作为 winuxsh 归因)
- bash rc=127(12 项):测试依赖编译产物/特殊环境(如
.sub调用./bash特定行为) - bash rc=2(10 项):语法错误用例(bash 报错、winuxsh rc=0 静默接受——属 [Bug 批量·第三轮] oil spec 大规模差分: alias 展开语义/语法错误接受度/数组赋值族/算术错误码/jobs-dirs 内置 - 219+ 项差异(已跑 1/2 套件) #22 语法宽松度家族,但需逐项复核)
- bash rc=124(6 项):bash 侧超时(测试含耗时/交互逻辑)
- bash rc=1/9(3 项)
这些需要 run-bash-upstream 脚本的完整环境(guard-bin、tmpdir、禁用 winuxcmd 等)才能可靠归因,建议后续用该脚本的 run-*.sh 逐个复核。
意义
- 「完整 GNU bash」的直接度量:官方 83 个测试本体中仅 14 个与 Git Bash 5.2 输出一致;37 个可靠差异说明 rubash 与当前 bash(5.2)的行为仍有系统性差距(
.right旧期望掩盖了这些差异) - 与四个套件(oil 684 / mksh 436 / ksh93 进行中 / 本 37 可靠项)交叉印证同一批根因族:命令替换状态污染、IFS 分词、语法宽松度、heredoc、coproc、set -e、调试钩子
复现
# winuxsh 仓库 scripts/probe/suites/
bash bash-tests-difftest.sh # bash 官方 83 tests (需 Git Bash, .sub 依赖 ./bash)
# 结果: bash-tests-results.txt; DIFF 行: bash-tests-diffs.txt驱动会把两侧 runner 复制为 tests/bash(.sub 调用),跑完清理。
Activity
caomengxuan666 commentedon Aug 12, 2026
2026-08-12 update: bash upstream .right runner 已重跑:scripts/run-bash-upstream-tests.sh 当前 86/87,唯一 run-minimal 为 exit 0 但 log 非空,和既有路径/环境噪音一致;结果在 target/bash-upstream-tests/results.tsv。注意这不是 #25 的 bash actual-output 83 全解决证据,actual-output 83 仍需要 winuxsh probe/suites/bash-tests-difftest.sh 驱动或等价 wrapper 继续跑。
caomengxuan666 commentedon Aug 12, 2026
2026-08-12 update: bash actual-output runner 已按 issue 描述在 rubash 仓库 target/issue-suites 下复刻并跑完(每个 .tests 隔离 workdir,Git Bash 5.2 vs target/debug/rubash.exe,结果见 target/issue-suites/results/bash-actual/results.tsv)。结果:TOTAL=83,PASS=15,DIFF=68。rc 形态:0/0=52(真实输出差异),2/0=11(Bash 报语法/用法错误但 rubash 静默 rc=0),127/0=12(环境/runner 或命令失败差异,需二次归因),124/0=5(bash 侧 timeout,按噪音/挂起再查),1/0=2,9/0=1。主要 DIFF 家族:parser/conditional/array strictness;arithmetic error propagation;heredoc + command substitution boundary;redirection/fd/device handling(含 /dev/null、ambiguous redirect、Bad fd);alias/hash;IFS/quoting/array expansion;glob/extglob/brace;builtin option/error parity;jobs/coproc/process substitution。已整理本地汇总:target/issue-suites/results/issue-suite-summary.md。
arookieofc commentedon Aug 13, 2026
Bash 官方 heredoc/comsub 真实语义切片已推进:run-heredoc、run-comsub、run-comsub-eof、run-comsub-posix、run-redir、run-vredir、run-procsub 全部通过(7/7)。
arookieofc commentedon Aug 14, 2026
Fixed in commit f0c1636.
Root cause: redirect targets were flattened to one string before execution, so an unquoted parameter expansion containing whitespace was treated as a literal filename. The common command execution boundary now rejects ambiguous unquoted redirect targets with Bash-compatible status 1 and diagnostic, while quoted targets remain valid.
Verification:
arookieofc commentedon Aug 14, 2026
Fixed in commit aee928d for two actual-output families: non-interactive alias gating and fatal arithmetic expansion errors. Focused Bash/Rubash probes and regressions pass; the broader 83-test actual-output aggregate remains open.
arookieofc commentedon Aug 14, 2026
2026-08-14 follow-up: the Bash-facing executor and CLI regressions for readonly variables, conditional parsing, process substitution, and fd redirects now pass. Verification: executor 1523/1523, CLI 155/155. The direct Bash 83-test differential inventory remains open.
arookieofc commentedon Aug 17, 2026
2026-08-17 follow-up (commit 62c64eb): fixed the remaining focused external pipeline and persistent-fd boundary cases. The Windows path now streams yes/head/wc through OS pipes when those utilities are unavailable, preserves persistent exec 2>&1 through cat pipelines, handles /usr/bin/cat diagnostics, and passes prefix assignments to env pipeline stages. Evidence: external_pipeline 4/4; persistent stderr regressions 2/2; prefix assignment regression 1/1; full cli_tests 229/229; full executor_tests 1535/1535. Official Bash actual-output aggregate and other suite families remain open.
arookieofc commentedon Aug 17, 2026
2026-08-17 follow-up (commits 349d06e, 784ce7d): fixed a shared ordered-output redirect boundary for builtin printf and pwd. Their direct redirect branches bypassed parse-order fd application; for
>&2 2>file, Bash keeps output on the original stderr but still creates an empty target, while Rubash previously skipped target creation. Both builtins now buffer stdout/stderr through the shared ordered fd owner. Evidence: fd_redirects 16/16; executor command_chaining::part_021 12/12; parser_redirection_tests 68/68; command_chaining::part_080 152/152; run-redir 1/1; cargo check passed. The broader issue-suite rows remain open.caomengxuan666 commentedon Aug 28, 2026
关闭说明
旧口径 "PASS 仅 14/83" 完全过时,当前状态:
13 个真 bug 已在 #43 和各子 issue 中逐项跟踪。详见
docs/bash-83-test-root-cause-analysis.md。