Repository navigation
fix(xtrace): complete G16 - single raw (( )) trace, for/case heads, assignment prefix - #107
Merged
Merged
Conversation
`set -x` traced `(( n ))` twice: once through the generic simple-command site (words join prints the normalized `(( n ))`) and once through execute_arithmetic_command (trim_start prints `(( n ))`). GNU traces it exactly once, with the verbatim between-parens text on both sides: `+ (( n ))` (execute_cmd.c:3940 passes the word to xtrace_print_arith_cmd without normalization; the generic execute_cmd.c:4480 simple-command trace never fires for arithmetic commands). - executor/command_dispatch.rs + command_prepare.rs: skip the generic xtrace for arithmetic command nodes (execute_arithmetic_command owns it) - executor/prompt_expansion.rs: add xtrace_print_arith_cmd_raw (no trim_start) for the plain-command path; the arith-for init/test/update paths keep the trimming variant, which already matches GNU byte-for-byte (`for (( i=0; i<2; i++ ))` traces `+ (( i=0 ))`, `+ (( i<2 ))`, `+ (( i++ ))`) Verified: upstream third_party/bash/tests set-x.tests now matches set-x.right 72/72 (CRLF-normalized); targeted A/B against WSL /usr/local/bin/bash 5.3.0(1) byte-identical for plain (( )), let, and arith-for forms; cargo test --lib 397 passed. 🤖 Generated with [WorkBuddy](https://workbuddy.cn)
…ollow-up) GNU traces three more shapes that rubash's `set -x` missed on LF scripts: - for head, once per iteration (execute_cmd.c:3062 -> xtrace_print_for_command_head, print_cmd.c:609): `for i in 0 1 2` traces `+ for i in 0 1 2` before each body run; the implicit `for i;` form traces the literal `+ for i in "$@"` (map_list keeps the unexpanded "$@"). - case head, once before pattern expansion (execute_cmd.c:3679 -> xtrace_print_case_command_head, print_cmd.c:742): `case abc in`. - assignment prefix on its own line (execute_simple_command trace): `foo=one echo hi` traces `+ foo=one` then `+ echo hi`, not one joined line. Implemented via xtrace_print_for_command_head emission in the iteration loop (loop_select.rs), a head trace in execute_case_command (compound_exec.rs), and an xtrace_assignment_text split at both generic trace sites (command_dispatch.rs / command_prepare.rs, helper in prompt_expansion.rs). Verified byte-identical against WSL /usr/local/bin/bash 5.3.0(1) for plain for / `for i;` / case / assignment-prefix forms; cargo test --lib 397 passed; upstream set-x.tests diff shrank from 39 to 13 lines (the rest is the BASH_XTRACEFD and xtrace word-quoting gaps, tracked separately in tests/gnu-compat/GAPS.md). 🤖 Generated with [WorkBuddy](https://workbuddy.cn)
caomengxuan666
added a commit
that referenced
this pull request
Sep 16, 2026
…as-char sites - README/README.zh-CN: new "Fixed today" section covering niubash #106 (CRLF line-terminator handling), #107 (-c GNU first-non-option-argument), #108 (type output capture), plus the nameref/history convergence and the debug-instrumentation cleanup from the local batch landing. - check-utf8-boundary-hygiene: extend the execution_misc.rs allowlist entry with the two reviewed byte->char widening patterns introduced by the batch: `out.push(byte as char)` under the 0x20..=0x7e printable-ASCII arm and the octal digit math `b'0' + ((byte >> n) & 0o7)` (always 0x30..0x37) — both can never involve a UTF-8 continuation byte.
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.
Closes two xtrace sub-gaps of tests/gnu-compat/GAPS.md G16, verified byte-identical against WSL
/usr/local/bin/bash5.3.0(1).(( ))双打印 + 格式(565ba986)set -x下(( n ))之前打两行(通用站点 + arith 专点各一次),且格式与 GNU 不符。GNU 只打一行并保留括号间原文:+ (( n ))(execute_cmd.c:3940,通用 simple-command trace 对算术命令不生效)。xtrace_print_arith_cmd_raw(不 trim_start)给普通(( ))路径;for ((...))的 init/test/update 继续用 trim 变体(本就逐字节正确)for/case 头与赋值前缀(79aac755)
for i in 0 1 2每次迭代打+ for i in 0 1 2;for i;隐式形式打字面+ for i in "$@"+ case abc infoo=one echo hi→+ foo=one++ echo hi(GNU 分两行,rubash 之前拼一行)验证
(( ))/let/for ((...))/ plain for /for i;/ case / 赋值前缀全部逐字节一致附带:GAPS.md 复核记录(8811ce2c)
本轮双端探针复核发现 ledger 多条已过时(G8①/G13/G9/G10/G23/G1 均已在近期提交中修好),已更新;同时记入新发现的 varenv 非确定问题。
🤖 Generated with WorkBuddy