Skip to content

[bug] set -x misses the '+ f' function-invocation trace line (GNU prints '+ f' before the body's '+ echo ...'; rubash prints body traces only) #247

Closed

Description

@caomengxuan666

Found by: wt4/regfix lane issue round (2026-09-27), script-file-verified against WSL GNU Bash 5.3.0 (/usr/local/bin/bash).

Summary: Under set -x, GNU prints one trace line per function invocation — the command head + f — before the body's own traces. Rubash skips the + f line entirely.

Reproducer (LF script file, identical bytes both shells; target/issue-suites/results/wt4-regfix/issue-probes/p1-xtrace-fn.sh):

set -x
f() { echo body; }
f
set +x
echo done

GNU Bash 5.3.0 stderr:

+ f
+ echo body
+ set +x

rubash stderr (wt4/regfix debug build):

+ echo body
+ set +x

(stdout body / done identical; only the invocation trace line is missing.)

GNU C source owner: execute_cmd.c:4649 execute_simple_command — the command-head xtrace_print_word_list (words, 1) runs before the function/builtin/external dispatch, so a word that resolves to a function still gets its head trace (+ f); the body then traces its own commands in the same shell.

Rubash owner: src/executor/command_dispatch.rs:38-47 — xtrace_command_lines(cmd) traces only the function's internal command lines for a function invocation; the invocation head line is not emitted. (Arithmetic commands are deliberately excluded there per #88; functions must not be.)

Classification: rubash-caused (WSL GNU 5.3.0 oracle). Severity: xtrace output is not byte-comparable for any traced script that calls functions (nvm.sh trace, bashdb set -x debugging, CI xtrace logs).

Artifacts: target/issue-suites/results/wt4-regfix/issue-probes/p1-xtrace-fn.sh (+ .gnu.out/.gnu.err/.rb.out/.rb.err captures).

Activity

  1. added
    bug
    on Sep 27, 2026
  2. caomengxuan666 commented on Sep 27, 2026

    @caomengxuan666
    MemberAuthor

    已修复并合入 master(commit 160d31b1,lane wt5/misc;GNU 引用与全矩阵验证见提交;相邻真 bug(v=$(f) 在 set -x 下双执行函数体)已一并修复)。感谢报告!

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions