Skip to content

[P2][裁决] 字节精确 stem 契约(#799)使 System32 大写工具小写不可达:ping/netstat/tracert 全 127 #998

Closed

Description

@caomengxuan666

现象(owner 实测复现,niubash 1.4.1 交互会话)

$ where ping
C:\\Windows\\System32\\PING.EXE
$ which ping
C:/Windows/system32/ping.exe
$ ping
niu: ping: command not found
$ PING          # 能跑
$ ping.exe      # 同样 not found(带扩展名也要求 stem 字节一致)
$ hash -r && ping   # 清缓存无效

根因(非 bug 路径,是 #799 刻意契约的代价)

src/executor/path.rs::find_in_path_via_listings 按 rubash#799 立约:命令 stem 必须字节精确,只允许 PATHEXT 扩展名部分 ASCII-CI。PING.EXE 在盘上是大写,故 ping/ping.exe 恒 miss、返回 127。

#799 的动机成立且真实:source 纯 gitconfig alias 文件时小写 r 字节折叠到 R.exe 启动 GNU R REPL 吞掉会话。当时的修法是对标 GNU/Linux 语义(大小写敏感 fs 上 r/R 是两个命令)。

冲突点:Windows 现实

System32 常驻一批全大写落盘的核心工具——PING.EXE、NETSTAT.EXE、TRACERT.EXE、ROUTE.EXE、PATHPING.EXE、ARP.EXE、HOSTNAME.EXE 等。Windows 生态(cmd/PowerShell/用户肌肉记忆/全部文档)一律小写敲命令,Git Bash/MSYS bash 也靠 NTFS stat 天然折叠、小写可用。当前契约下这些工具必须大写敲才能跑——对 Windows 壳这是日常可用性级别的退化,且 which/where(Windows 侧折叠)与执行器(字节精确)答案互相矛盾,用户视角就是"明明在 PATH 里却 not found"。

裁决请求

#799 危害(小写名意外启动外来 REPL)与 Windows 工具可达性之间存在真实张力,两条路都有代价:

需要 owner 拍板取舍。一个相对干净的中间档候选:stem 折叠仅在"折叠后全 PATH 唯一命中且无字节精确命中"时生效——ping→PING.EXE(唯一)通,r→R.exe(若 r/R 同名冲突或习惯反例存在时)仍按 #799 拒绝。是否成立请裁决。

相关:tests/issue799_command_name_case_regressions.rs(现契约的测试钉)、src/executor/path.rs:538-611(fold arm 仅扩展名 CI)。

Activity

  1. caomengxuan666 commented on Oct 22, 2026

    @caomengxuan666
    MemberAuthor

    修复已由 #1000 落地(owner 拍板 A:stem ASCII-CI,exact 优先)。ping/netstat/tracert/hostname 在 rubash 引擎侧全部可达;本票与 #999 同内容,#999 已随 #1000 自动关闭,本票手工收口。随 niu 下一版本携带。

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