Skip to content

[bug] time 操作数层把带引号的 '-p' 当作自身选项(GNU 视为被计时命令名) #1548

Closed

Description

@caomengxuan666

time 的操作数层把带引号的 dash 词当作 time 自己的选项:time '-p' true 中引号内的 -p 在 GNU 是被计时命令的命令名(引号使其不参与 time 的选项识别),rubash 在词展开去引号后按 -p 选项执行、以 posix 格式计时跑 true,rc 0。所有模式下均如此(与 posix 无关),#1520 集成验证时对拍测出,修复前二进制(master 1e72c7f)非 posix 下行为相同、属先行分歧;posix 下 #1520 前是执行期 veto 误打误撞出的 127(理由错),#1520 后裁决层已与 GNU 一致(time 保关键字),剩操作数层这一处未合。

复现(GNU bash 5.3.20 对拍):

PATH=/nonexistent; time '-p' true; echo rc=$?
  • GNU:-p: command not found + 默认格式计时,rc=127('-p' 是被计时命令的头词)
  • rubash:posix 格式计时、无诊断,rc=0(把 -p 当 time 的选项、计时对象成了 true)

同族探针(修复时一并对齐):time "-p" true、time -p '-p' true(第二个 -p 应为命令名)、time -- '-p'、time \-p true(转义形 GNU 在读入期瞥原始字符、同样不作选项)。

Regression seed:期望按上述 GNU 行为写(rc 与「-p 作命令名未找到」诊断 + 计时仍输出),脚本自包含,测试名带本 issue 号,与修复同 commit。

Activity

  1. added a commit that references this issue on Oct 25, 2026
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions