Skip to content

Comments

feat(interpreter): implement set -x xtrace debugging#253

Merged
chaliy merged 2 commits intomainfrom
claude/bashkit-bash-compatibility-BsDKD
Feb 24, 2026
Merged

feat(interpreter): implement set -x xtrace debugging#253
chaliy merged 2 commits intomainfrom
claude/bashkit-bash-compatibility-BsDKD

Conversation

@chaliy
Copy link
Contributor

@chaliy chaliy commented Feb 24, 2026

Summary

  • Implement set -x xtrace which traces simple commands to stderr before execution
  • Trace shows expanded argument values prefixed by PS4 (default + )
  • Like real bash, xtrace output goes to the shell's stderr and is not affected by per-command redirections like 2>&1
  • set +x properly disables tracing (and is itself traced)

Test plan

  • 5 spec tests verify stdout is unaffected by xtrace
  • 6 unit tests verify stderr contains correct xtrace output
  • Unit test verifies 2>&1 does NOT capture xtrace (matching real bash)
  • Unit test verifies set +x is traced then disables tracing
  • All existing tests pass
  • cargo clippy clean, cargo fmt clean

Implement xtrace (set -x) which traces simple commands to stderr before
execution. The trace shows expanded argument values prefixed by PS4 (default
"+ "). Like real bash, xtrace output goes to the shell's stderr and is not
affected by per-command redirections like 2>&1.

- Add is_xtrace_enabled() checking both options.xtrace and SHOPT_x
- Build trace line in execute_simple_command with expanded args
- Prepend trace to ExecResult.stderr after dispatch
- 5 spec tests (stdout unaffected by xtrace) + 6 unit tests (stderr content)
@chaliy chaliy merged commit b844983 into main Feb 24, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants