Skip to content

[Bug 批量·第六轮] bash 官方 83 tests 差分: PASS 仅 14/83, 37 项可靠差异 - 官方测试与 GNU Bash 实际输出的一致性差距 #25

Closed

Description

@caomengxuan666

[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)

3. glob 家族(glob / globstar / extglob)

4. 选项/错误语义(set-e / set-x / test / posixpipe)

5. 其他(appendop / assoc / attr / braces / case / cond / coproc / dbg-support / exp / func / getopts / heredoc / history / intl / invocation / mapfile / rsh / tilde2 / varenv / vredir)

其余 32 项(bash 侧 rc 非零,不作为 winuxsh 归因)

这些需要 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

  1. caomengxuan666 commented on Aug 12, 2026

    @caomengxuan666
    MemberAuthor

    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 继续跑。

  2. caomengxuan666 commented on Aug 12, 2026

    @caomengxuan666
    MemberAuthor

    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。

  3. arookieofc commented on Aug 13, 2026

    @arookieofc
    Member

    Bash 官方 heredoc/comsub 真实语义切片已推进:run-heredoc、run-comsub、run-comsub-eof、run-comsub-posix、run-redir、run-vredir、run-procsub 全部通过(7/7)。

  4. arookieofc commented on Aug 14, 2026

    @arookieofc
    Member

    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:

    • cargo test --test cli_tests fd_redirects: 12/12
    • cargo test --test cli_tests -- --nocapture: 150/150
    • cargo test --lib: 163/163
    • scripts/run-bash-upstream-tests.sh run-redir: 1/1
  5. arookieofc commented on Aug 14, 2026

    @arookieofc
    Member

    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.

  6. arookieofc commented on Aug 14, 2026

    @arookieofc
    Member

    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.

  7. arookieofc commented on Aug 17, 2026

    @arookieofc
    Member

    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.

  8. arookieofc commented on Aug 17, 2026

    @arookieofc
    Member

    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.

  9. caomengxuan666 commented on Aug 28, 2026

    @caomengxuan666
    MemberAuthor

    关闭说明

    旧口径 "PASS 仅 14/83" 完全过时,当前状态:

    对比方式 结果
    .right 期望文件对比 83/87 PASS (95.4%)
    实际输出 vs GNU Bash 13 完全一致
    平台噪音 (非bug) 16 个
    rubash 优于 bash 3 个
    真正需要修的 bug 13 个

    13 个真 bug 已在 #43 和各子 issue 中逐项跟踪。详见 docs/bash-83-test-root-cause-analysis.md。

  10. added
    bug
    gnu-baseline
    on Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggnu-baseline

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions