Skip to content

[xtrace] case 跟踪丢引号且泄漏内部标记 0x13:+ case $x^S in(GNU + case "$x" in) #517

Closed

Description

@caomengxuan666

复现

set -x; x=hi; case "$x" in hi) :;; esac
stderr rc
GNU bash 5.3.0 + x=hi / + case "$x" in / + : 0
rubash 764b9dd + x=hi / + case $x<0x13> in / + : 0

cat -A 视角:rubash 的 case 跟踪行是 + case $x^S in——0x13 内部标记字节直接输出,且 $x 的引号(bash 按"需要引号的词加引号"规则显示 "$x")丢失。

根因

xtrace 渲染复用了内部标记形式的词(0x13 为 rubash 内部引用标记),既未转义剥离也未按 bash 的 trace 引号规则重排。

规范/源码依据

  • bash xtrace:打印的词按可安全粘贴回 shell 的形式渲染(bash 手册:trace 输出"可以重新粘贴执行")——含引号的词显示为 "$x"。
  • 内部控制字节(CTLESC 类标记)绝不应出现在用户可见输出。

跨实现互证(huck)

证据

  • 语料出处:xtrace_compound_diff_check.sh:14(F107,label: case match)
  • 复核:764b9dde 仍复现(cat -A 显示 ^S);旧构建 41de831 行为一致

Activity

  1. added
    bug
    P3-low
    on Oct 12, 2026
  2. caomengxuan666 commented on Oct 12, 2026

    @caomengxuan666
    MemberAuthor

    Fixed by #569 (Wave3). Vendored-bash anchors and RED-then-GREEN regression evidence in the PR.

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

    P3-lowbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions