Skip to content

[path][P2] POSIX absolute-path operand translation drifts by execution context: sed/du fail inside for-loops/subshells, fine at top level #592

Closed

Description

@caomengxuan666

niu -c 'for i in 1; do sed -n 1p /d/repo/rubash/Cargo.toml; done' -> ENOENT; the same command without the loop succeeds. find | xargs sed -i and find -exec sed fail down the chain. grep/wc/head carry their own POSIX layer and are fine; sed/du (no self-translation) fail in script contexts. __RUBASH_ARGV_DIALECT=legacy un-breaks it, so the pre-translation gate is context-sensitive. Related: #1170 (WinuxCmd-side /d/ gaps). Found in the 1.4.0 real-world sweep — the for/xargs + absolute-path + sed combo is a daily driver.

Activity

  1. added
    bug
    on Oct 13, 2026
  2. caomengxuan666 commented on Oct 13, 2026

    @caomengxuan666
    MemberAuthor

    Scope extension from a real agent incident (2026-10-13): the translation gap is not limited to sed/du in loops.

    New datapoint — git worktree add /d/repo/niubash-wt-291 ... issued from niu created the worktree at D:/d/repo/niubash-wt-291 (the /d/... operand was resolved as current-drive-root-relative by the native git), while git -C /d/repo/rubash status translates fine. So the pre-translation layer is parameter-position and/or existence sensitive: -C <existing path> translates, worktree add <new path> does not.

    Implications:

    1. Every external command that takes a to-be-created path operand (worktree add, mkdir, tee, cp dest, output redirects are fine but argv-based dests are not) can land at the wrong drive-root location — silently.
    2. niugit is Windows-native by adjudication (no MSYS layer, unlike Git for Windows which digests /d/... itself), so the rubash pre-translation layer is the only place this can be fixed.
    3. Fix contract should be: translate path-shaped operands for external commands regardless of context (script/loop/subshell), parameter position, and target existence — the fix(path): translate /mnt/X drive argv for every child class (niubash#164) #444/边界契约审计:三不变量契约测试 + windows-path-contract 文档 + 代理驱动指南 #570 contract claims this coverage already; the implementation is context-sensitive.

    Repro hint for the fixer: compare git -C /d/repo/rubash status (translates) vs git -C D:/repo/rubash worktree add /d/repo/wt-test branch (does not) on current master.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions