Skip to content

winuxcmd: cp 等命令不接受 POSIX 绝对路径(/bin/sh 被解析为盘根相对) #99

Closed

Description

@caomengxuan666

(跨仓 winuxcmd,从 rubash 平台差异挖出)

rubash/winuxcmd 环境下 cp /bin/sh /tmp/x 报 cannot stat '/bin/sh':winuxcmd cp 把 POSIX 风格绝对路径 /bin/sh 解析为 <当前盘>:\bin\sh。而同环境的 GNU ls 能正确解析 /bin/sh(MSYS 转换)。

建议:winuxcmd 对看起来是 POSIX 绝对路径的参数做转换(探测 MSYS/Git 根或提供 cygpath 语义),或至少在 cp/ln/mv 等文件命令上。

影响:rubash gnu-compat 套件 rsh/posixexp 等的平台类差异大半由此而来(见 rubash 仓库 tests/gnu-compat/GAPS.md A2/A12/G27)。

Activity

  1. caomengxuan666 commented on Sep 14, 2026

    @caomengxuan666
    MemberAuthor

    归因错误,关闭本 issue。实测结论(2026-09-14):

    1. POSIX 路径转换是 shell 层职责,且 rubash 已经实现:src/executor/path.rs 的 external_argument_path 在 spawn 边界转换——/tmp、/dev/*、/mnt/X 无条件转换;/bin、/etc、/usr、/var 在配置了 shell 根(WINUXSH_ROOT/RUBASH_ROOT,经 map_logical_path 字面映射)后也转换。niu.exe 实测转换正常(/bin/sh → <安装根>\winuxcmd\bin\sh)。
    2. 当初观察到的 cp /bin/sh 失败不是 winuxcmd 缺转换,而是 gnu-compat 测试 harness 直接跑 rubash.exe 时没有配置 WINUXSH_ROOT,/bin 等分支不激活,参数原样透传。
    3. 修复在 harness 层(rubash 仓库 run-83.sh):构造最小 fixture 根(bin/sh 无 .exe 后缀字面名 + etc/passwd + tmp/var/home 目录),run_rubash 导出 WINUXSH_ROOT 指向它。实测 cp /bin/sh /tmp/x rc=0、cat /etc/passwd 正常——rubash 自己的转换机制接管。
    4. 附带发现:map_logical_path 按字面名 exists() 检查,MSYS cp 会把复制目标自动改名 sh.exe,导致字面 sh 不存在——fixture 用 cat /bin/sh > bin/sh 规避。

    coreutils 侧无需任何改动。

  2. added
    bug
    area:path
    on Oct 17, 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

    area:pathbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions