Repository navigation
Closed
Labels
Description
[Bug 批量·第五轮] 全量清单聚焦: umask/trap/kill/set/echo/cd 内置族 / sh-options / word-split / var-op / nameref / mksh 进制字面量 —— oil 684 + mksh 436 项完整清单
背景
oil spec(228 文件)与 mksh check.t(627 块)全量差分完成(GNU Bash 5.2 基准,逐字节对比 stdout+rc)。本轮是 #23 评论完整清单的高频领域聚焦:每个领域给出代表用例与 rc 模式,供修复排序。完整清单:winuxsh 仓库 scripts/probe/suites/diffs-full.txt(oil 684)+ mksh-diffs-full.txt(mksh 436)。
一、内置命令族整体异常(oil spec,约 120 项)
1.1 umask(18 项)—— 内置整体失效
umask # bash rc=0 打印当前掩码; rubash rc=1
umask -S # 符号打印: bash rc=0; rubash rc=1
umask 0002 # 设置: bash rc=0; rubash rc=1
umask g-w,o-w # 符号模式: bash rc=0; rubash rc=1
umask s perm / t perm / permcopy / sequential actions # bash rc=127; rubash rc=1
- 除
large octal number(两侧 127)外几乎全灭——umask 内置的符号模式解析与基本打印/设置全部异常。
1.2 trap 家族(37 项 = builtin-trap-err 20 + builtin-trap 17)
- [Bug 批量] 命令替换状态污染 / heredoc / case 模式 / 参数替换 / 路径转换 / 重定向 / 调试钩子 - 20+ 个与 GNU Bash 的兼容性差异(含最小复现) #20 §6 已列 DEBUG/RETURN/EXIT 不触发;全量清单显示更广:ERR 语义、trap 列表、trap -p/-l、子 shell 传播、字符串求值时机等 37 项差异。
1.3 kill(15 项)
kill -l信号列表、kill -s、无信号名、负 PID 等:bash 正常(rc=0/1)/ rubash 错误码不同(多数 rc=1 或 127)。
1.4 set(12 项)+ sh-options(23 项)
shopt -p -o/shopt -o(bash rc=0 打印选项 / rubash rc=1——shopt 打印 set 选项失败)shopt with no flags(bash rc=127 / rubash rc=1)nounset/-u is nounset(bash rc=1 / rubash rc=127——错误码差异)pipefail(bash rc=127 / rubash rc=9——rc=9 异常)vi and emacs are mutually exclusive(bash rc=127 / rubash rc=1)noclobber on、$- with pipefail(两侧 rc=0 输出不同)
1.5 echo(12 项)/ process(12 项)/ cd(11 项)
- echo:typed args(bash rc=2 / rubash rc=0)、
\0377八进制边界(两侧 127 输出不同) - process:
$!语义、后台进程状态 - cd:
cd-history(bash rc=2 / rubash rc=127)、cd -往返、目录栈
二、word-split / IFS(35 项, word-split.test.sh + toysh-posix)
$*/$@/"$@"/$* with empty IFS(两侧 rc=0 输出不同——[Bug 批量·第二轮] 花括号展开/IFS 分词/glob 路径分隔符/BASHPID/进程替换/coproc 挂起/wait 错误/特殊内建管道扩展 - 11 项新差异(全部经 GNU Bash 对照) #21 §1.2/§1.3 家族的大规模扩展)Word elision with non-whitespace IFS(两侧 127 输出不同)IFS=x and '' and unquoted $@(两侧 127 输出不同)- 与 [Bug 批量·第二轮] 花括号展开/IFS 分词/glob 路径分隔符/BASHPID/进程替换/coproc 挂起/wait 错误/特殊内建管道扩展 - 11 项新差异(全部经 GNU Bash 对照) #21 §1.2(空字段被吞)、§1.3(
"$*"未用 IFS)互证:IFS 分词是全量清单最大单文件差异源之一。
三、var-op 家族(48 项)
var-op-test(14):${v=}/${v:-}/${v:+}/${v:?}组合错误处理var-op-slice(11):${v:off:len}负偏移/越界([Bug 批量·第三轮] oil spec 大规模差分: alias 展开语义/语法错误接受度/数组赋值族/算术错误码/jobs-dirs 内置 - 219+ 项差异(已跑 1/2 套件) #22 已有 out-of-bound,此处更多形态)var-op-patsub(10):${v//pat/rep}([Bug 批量] 命令替换状态污染 / heredoc / case 模式 / 参数替换 / 路径转换 / 重定向 / 调试钩子 - 20+ 个与 GNU Bash 的兼容性差异(含最小复现) #20 §2.5 反斜杠/换行家族扩展)var-sub-quote(13):引号内子串/替换- mksh 侧 varexpand-*(15):substr/special/null 细节
四、其他高频
- parse-errors(16):语法错误接受度([Bug 批量·第三轮] oil spec 大规模差分: alias 展开语义/语法错误接受度/数组赋值族/算术错误码/jobs-dirs 内置 - 219+ 项差异(已跑 1/2 套件) #22 §B 家族;含
parse-errors专用文件) - redirect-multi/command(22):重定向([Bug 批量] 命令替换状态污染 / heredoc / case 模式 / 参数替换 / 路径转换 / 重定向 / 调试钩子 - 20+ 个与 GNU Bash 的兼容性差异(含最小复现) #20 §5.1 2> 家族扩展,含多目标/命令重定向)
- nameref(11):
declare -n引用变量 - errexit-osh(11):set -e([Bug 批量] 命令替换状态污染 / heredoc / case 模式 / 参数替换 / 路径转换 / 重定向 / 调试钩子 - 20+ 个与 GNU Bash 的兼容性差异(含最小复现) #20 §3.2 家族)
- extglob-match(10):extglob([Bug 批量·第四轮] 三套件差分: oil spec 补全(427+ DIFF)/mksh check.t(153+ DIFF)/ksh93 tests - alias/数组/算术/heredoc/eglob/expand/错误码(后台全量继续中) #23 §1.3 家族)
- command-sub(15):命令替换([Bug 批量] 命令替换状态污染 / heredoc / case 模式 / 参数替换 / 路径转换 / 重定向 / 调试钩子 - 20+ 个与 GNU Bash 的兼容性差异(含最小复现) #20 §1 家族)
- background(18):jobs/wait([Bug 批量·第二轮] 花括号展开/IFS 分词/glob 路径分隔符/BASHPID/进程替换/coproc 挂起/wait 错误/特殊内建管道扩展 - 11 项新差异(全部经 GNU Bash 对照) #21 §2.2 家族)
- brace-expansion(16):[Bug 批量·第四轮] 三套件差分: oil spec 补全(427+ DIFF)/mksh check.t(153+ DIFF)/ksh93 tests - alias/数组/算术/heredoc/eglob/expand/错误码(后台全量继续中) #23 §6 家族
- alias(16+12):[Bug 批量·第三轮] oil spec 大规模差分: alias 展开语义/语法错误接受度/数组赋值族/算术错误码/jobs-dirs 内置 - 219+ 项差异(已跑 1/2 套件) #22/[Bug 批量·第四轮] 三套件差分: oil spec 补全(427+ DIFF)/mksh check.t(153+ DIFF)/ksh93 tests - alias/数组/算术/heredoc/eglob/expand/错误码(后台全量继续中) #23 alias 家族(三套件互证)
五、mksh 专属新领域(436 项中 oil 没有的)
5.1 integer-base 进制字面量(29 项)
echo $(( 2#110 )) # bash: 6 (bash 支持 n#base!);
# 用例如 integer-base-one / integer-base-err: bash 对 2# 语法报 invalid number (rc=1)
# rubash 多数 rc 与 bash 不同 (rc=0/1/127 混杂) — 进制字面量解析差异
- mksh 的
n#base形态(2#110、16#ff)在 bash 与 rubash 间行为不一致,29 项。
5.2 heredoc-tmpfile(8)+ heredoc-comsub(4)
- heredoc 写临时文件/heredoc 内命令替换形态([Bug 批量·第四轮] 三套件差分: oil spec 补全(427+ DIFF)/mksh check.t(153+ DIFF)/ksh93 tests - alias/数组/算术/heredoc/eglob/expand/错误码(后台全量继续中) #23 §2.4 家族)。
5.3 better-parens(13)
- 括号解析(
( )组合、算术括号上下文)。
5.4 其他
wcswidth(6):宽字符宽度计算lineno(5):$LINENO(ksh93 侧也见$LINENO展开错误——跨套件互证)history-subst(4):!!历史替换utf(4)、exit-err(6)、exit-trap(4)、bashiop(8)、oksh-seterror(7)、xxx-variable-syntax(4)
修复优先级建议
- umask(整体失效,1.1)与 shopt -p/-o 打印(1.4)——影响脚本配置读取
- word-split/IFS(35+)——最高频单文件
- trap 家族(37)——[Bug 批量] 命令替换状态污染 / heredoc / case 模式 / 参数替换 / 路径转换 / 重定向 / 调试钩子 - 20+ 个与 GNU Bash 的兼容性差异(含最小复现) #20 §6 的补全
- var-op 家族(48)——脚本最常用语法
- mksh integer-base(29)——解析器进制支持
- 其余按清单
复现
# winuxsh 仓库 scripts/probe/suites/
bash spec-difftest.sh # oil: PASS=1083 DIFF=684
bash mksh-difftest.sh # mksh: PASS=183 DIFF=436
# 清单: diffs-full.txt / mksh-diffs-full.txt; 完整结果: spec-results.txt / mksh-results.txtksh93 tests 58 文件仍在后台运行(每文件 60s 超时保护),完成后追加到 #23 评论。
Activity
caomengxuan666 commentedon Aug 12, 2026
2026-08-12 update: kill 子项追加修复已提交 47924f4。原因是 rubash-to-rubash signal mailbox 会截获带 mailbox 的 rubash 进程信号;SIGKILL 不可捕获,之前也会被 mailbox 派发吞掉,导致挂住的 rubash 子进程无法强杀。现在 SIGKILL 绕过 mailbox,直接走 Windows native TerminateProcess;Windows kill 权限也降到 PROCESS_TERMINATE,贴近 winuxcmd kill 的最小权限路径。验证:cargo test --test cli_tests c_command_kill_ -- --nocapture = 5/5;cargo test --test cli_tests c_command_background_kill_shell_pid_runs_term_trap -- --nocapture = pass;cargo test --lib = 153/153。
arookieofc commentedon Aug 13, 2026
Fixed and committed as 44617c8: kill option scanning now treats operands after explicit -s/-n correctly, so kill -s 0 -1 matches Bash's signal-zero process-group probe (status 0). Added regression test in executor command-chaining part_026 (15/15 pass). The issue remains open for its other builtin families.
arookieofc commentedon Aug 13, 2026
修复并提交 shopt -o 输出格式差异:非 -p 形式现在输出
pipefail off等可读格式,-p 仍输出可重放的set +/-o。验证:Bash upstream run-shopt 1/1,cargo test --lib 163/163。arookieofc commentedon Aug 13, 2026
补充修复参数替换反斜杠边界(覆盖 path/var-op 家族):part_024 13/13,Bash/Rubash 直接对照一致。
arookieofc commentedon Aug 14, 2026
Fixed in commit 1665d23. The word-split/IFS slice now matches Bash for repeated custom whitespace delimiters. Full Rust lib and CLI regressions pass; other aggregate issue families remain open.
arookieofc commentedon Aug 14, 2026
Follow-up fix in commit e0242d2: corrected loop-control status to match direct GNU Bash 5.2 behavior. Out-of-loop break/continue keep status 0 after the diagnostic; focused part_050 tests pass (14/14).
arookieofc commentedon Aug 14, 2026
Fixed in commit aee928d. The alias and arithmetic-error slices now match direct GNU Bash 5.2 behavior. Full lib (165) and CLI (155) tests pass; aggregate issue remains open for other families.
arookieofc commentedon Aug 14, 2026
Fixed in commit a0ccf47. Scalar parameter substring boundaries now match Bash: negative offsets beyond the value produce an empty expansion (for example ${v: -4} with v=abc), while negative lengths remain valid when the effective end is non-negative and report substring expression < 0 with status 1 when it is below zero. Added regressions in executor command-chaining part_063 and updated docs/issue-suite-diff-analysis.md. Verification: cargo test --test executor_tests test_parameter_substring_ (7 passed), cargo test --lib (165 passed), cargo test --test cli_tests (155 passed).
arookieofc commentedon Aug 14, 2026
Fixed in commit f8eefab.
umasksymbolic mode now matches GNU Bash grammar: bare classes (u,g,a) require an operator, and chmod-only permissions (X,s,t) are rejected. Validrwxand class-copy forms remain supported. Verification:cargo test --lib umask(6 passed),cargo test --test executor_tests umask(8 passed),cargo test --test cli_tests(155 passed).arookieofc commentedon Aug 14, 2026
Fixed in commit 3f90adf. The ambiguous-redirect guard now skips parser redirects marked HereString, so <<< $'alpha\nbeta' is treated as input data rather than a filename while ordinary file/fd redirects remain validated.
Verification: mapfile 25 passed, readarray 12 passed, fd redirect tests 14 passed, and bounded executor integration 1501 passed with 22 remaining failures in unrelated source/exec status, associative key, process substitution, conditional, and fd/process-substitution cases.
arookieofc commentedon Aug 14, 2026
Fixed in commit 16a1165. Ordered redirected output no longer resets a builtin's already-computed exit status. This restores missing-file/invalid-option statuses for source and command -V with stderr redirects; echo now records its own successful status explicitly. Focused source and command-description tests pass, while two exec diagnostic-capture cases remain under investigation.
arookieofc commentedon Aug 14, 2026
Fixed in commit d4a2e78. Option diagnostics from exec with no command operand now go through the redirected builtin output path. Invalid -Z and missing -a arguments therefore honor 2> while redirections remain persistent. Verification: exec-focused executor slice 122/122 and fd redirect tests 14/14.
arookieofc commentedon Aug 14, 2026
2026-08-14 follow-up: special readonly variables, associative-array keys, conditional order operators, fd copies, and
<>builtin redirects are covered and green. Verification: executor 1523/1523, CLI 155/155, lib 155/155. This does not yet close the full builtin/word-split/var-op inventory.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
关闭说明
已修复项:
剩余 oil/mksh 项是基础设施问题,在 #40/#41 中跟踪。关闭历史 issue。