Skip to content

[builtins] dirstack 族数字参数验证退出码错:dirs/popd/pushd 非数字 → rc=1,dirs -l +q 静默 rc=0(GNU 统一 2) #509

Closed

Description

@caomengxuan666

复现

dirs -Q
stdout+stderr rc
GNU bash 5.3.0 bash: line 1: dirs: -Q: invalid number + usage 行 2
rubash 764b9dd 消息完全一致 1

爆炸半径(复核时收窄了 bugs.md 的初判:不是"内建 usage 统一 rc=1")

一般内建 usage/invalid-option 在 rubash 是对的:pwd -Q / cd --foo / umask -Q / type -Q → rc=2 ✔。
错的集中在 dirstack 族数字参数验证:

探针 rubash GNU 5.3.0
dirs +x 1 2
dirs -Q 1 2
popd +x 1 2
pushd +q 1 2
dirs -l +q 0(静默通过!) 2

dirs -l +q 连错误都不报(rc=0 无输出),比 rc=1 更糟。

规范/源码依据

bash 内建的数字参数解析统一走 builtins/common.c get_numeric_arg():失败时 builtin_error("%s: invalid number", ...) 并返回 EX_USAGE(=2)。dirs/popd/pushd 的 ±N 参数同源(builtins/dirs.def)。

跨实现互证(huck)

证据

  • 语料出处:dirstack_args_diff_check.sh:33(fragment F045)
  • 复核:764b9dde 仍复现 + 上述扩展探针

Activity

  1. added
    bug
    P1-high
    on Oct 12, 2026
  2. caomengxuan666 commented on Oct 12, 2026

    @caomengxuan666
    MemberAuthor

    审计互证(huck 443-issue 全量对照,issues-audit we-diverge B4):本 issue 的爆炸半径表已被独立审计复现确认——pushd -Q / dirs -Q / popd -Q 三内建:消息与 usage 逐字一致(invalid number),rc 均 rubash 1 / GNU 2(huck 侧对应 huck#519 "pushd/popd/dirs: -N is a NUMBER in bash, not an option — and pushd -Q misroutes to cd",已修复)。语料出处:dirstack_args_diff_check.sh(fragment F045)。无需新开 issue,归并本条跟踪。

  3. caomengxuan666 commented on Oct 12, 2026

    @caomengxuan666
    MemberAuthor

    Fixed and merged (see the linked PR in timeline).

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

    P1-highbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions