Repository navigation
fix(path): translate /mnt/X drive argv for every child class (niubash#164) - #444
Merged
Merged
Conversation
…#164)
`cd /mnt/c` worked but `ls /mnt/c` (and every other external command)
failed on the same path. The builtin resolves through
`shell_path_to_windows`, which owns a `/mnt` branch; the external
argument funnel did not.
`/mnt/X` was classified with the verbatim drive forms (`/d/x`,
`/cygdrive/d/x`) on the premise that the child's own POSIX layer
resolves it. That premise holds for `/d/x` and `/cygdrive/d/x` —
WinuxCmd `normalize_api_operand_w` (`src/utils/native_path.cppm`) folds
`/cygdrive/d/...` into `/d/...` and then maps a bare `/X/...` drive
letter — but not for `/mnt/X`: that letter test requires a separator or
end-of-string after the letter, and `mnt` is `m` followed by `n`. A
repo-wide code search for `mnt` under unixwin/WinuxCmd returns only
docs and scripts, no parsing arm. No native exe has a POSIX layer at
all, so no child resolves the form.
That leaves `/mnt/X` in the same class as the virtual system roots
(niubash#164: shell-owned namespace the child cannot resolve), and the
same two constraints bound the fix: niubash#62 keeps the rule in the
shell layer (WinuxCmd must NOT change), and niubash#164 requires one
argv to arrive in one form for every child class ("要么都翻、要么都
不翻,不应按命令名单切分"). Translation also matches the form's
origin — `/mnt/d/...` is WSL's own spelling, which GNU writes verbatim
under WSL (rubash#329).
- new `windows_mnt_drive_argument()` owns the shape test
(`/mnt/X` or `/mnt/X/...`; `/mnt/cfoo` and `/mnt/123` are ordinary
words), and the inline copy in
`windows_external_absolute_argument_needs_translation` collapses onto
it so there is one source.
- `translated_virtual_system_root_argument` admits the form, so applets,
the dispatcher and native exes all receive `X:\...` like every other
root-class word.
- `/d/x` and `/cygdrive/d/x` stay verbatim, untouched.
Tests: `windows_mnt_drive_argument_translates_for_every_child` pins the
shape class, the applet spelling (`/mnt/c` -> `C:\`,
`/mnt/d/repo/x` -> `D:\repo\x`) and that the MSYS forms stay verbatim;
`windows_virtual_system_root_arguments_keep_option_b_shapes_verbatim`
drops `/mnt/c` from its verbatim list (that assertion encoded the wrong
premise). cfg(windows)-gated: cargo check --lib is the Linux-side line;
the test bodies need the Windows runner.
Member
Author
|
Cross-link: filed the reporting side as unixwin/niubash#208 (the user-visible symptom — Related design constraints, both already quoted in the PR body:
No new target is invented: |
caomengxuan666
added a commit
that referenced
this pull request
Oct 12, 2026
…ation - the /mnt contract belongs to the #444 translation tests (#574) The verbatim loop in virtual_system_root_operand_resolution_keeps_option_b_ and_legacy_verbatim (ea36410, #177) still listed /mnt/c, contradicting the #444 pin (46d7942) one file over - Windows --lib was permanently red. The #568 'audit evidence' that the toolchain resolves /mnt natively was measurement pollution: Git Bash converts /mnt/c -> C:\\ at spawn (MSYS2 WSL-interop), so ls.exe rc=0 tested Git Bash, not WinuxCmd. PowerShell side-by-side (no POSIX layer): /d/repo ok, /cygdrive/d/repo ok, /mnt/c/Windows ENOENT, touch rc=1 no file. Source audit to v1.1.6 (c40e939): normalize_api_operand_w only folds /cygdrive and single-letter /X/; zero /mnt commits v1.1.2..v1.1.6. - remove /mnt/c from the loop; comment pins the boundary (shape-class test proves windows_virtual_system_root_argument("/mnt/c") == false) and hands the /mnt contract to the #444 test, untouched - docs/windows-path-contract.md L2: correct the polluted 1.1.5 note and the violation ledger entry - feature ask for a native /mnt arm: WinuxCmd#1172 cargo test --lib executor::path: 68 passed (was 67+1). Full --no-fail-fast failure set identical to fresh master by name.
This was referenced Oct 13, 2026
caomengxuan666
added a commit
that referenced
this pull request
Oct 13, 2026
…d class, context/position/existence invariant (closes #592) (#600) * fix(path): POSIX drive-form operand pre-translation covers every child class, context/position/existence invariant (closes #592) The argv funnel handed drive-form operands (/d/...) to POSIX-aware children verbatim on the Option-B premise that each tool resolves them itself. The shipped toolchain breaks that premise three ways: sed/du 1.1.5 have no operand resolution at all (WinuxCmd#1178), usr/bin/git.exe existence-gates it (git -C /d/existing works while worktree add /d/new silently lands at D:\d\new), and the niubash host's name-list translation (normalize_winuxcmd_slash_drive_args) runs only at top-level AST points - so the same command drifted by execution context (issue #592: sed/du fail inside for-loops/subshells, fine at top level). The engine now owns path-form pre-translation for EVERY non-shell-wrapped child class: the POSIX-aware arm routes non-exempt words through external_argument_path (the native funnel), making the translation invariant across execution context (single funnel: -c, script files, loops, subshells, functions, pipelines, command substitution), argument position (positional operands, -C-style flag values, to-be-created targets - no existence gate outside the legacy hatch) and target existence. Data operands stay verbatim (invariant C, niubash#62 - shape cannot separate ls /d/ from grep -F /h/): argv_data_primary_positions ports the niubash host's winuxcmd_path_translation_mask table (grep/sed/awk first positional pattern/script/program text, find pattern-primary values) and adds the filesystem-blind string transforms basename/dirname (GNU dirname.c/basename.c never stat their operand; issue71 pins dirname /a/b/c.txt -> /a/b). All pre-existing exemptions keep their exact behavior: natives, shell-wrapped children, /cygdrive/d (folds in-child, #568 probe), /dev/*, bare /, cmd switches, attached --opt=/x values, the env channel, rev specs. __RUBASH_ARGV_DIALECT=legacy reverts the whole widening to the pre-#592 existence-gated funnel. Superseded pins flipped (#444 precedent): /c/Windows and /d/x verbatim pins for the applet class now assert the translated form; the B2 negative ls-$nosuchvar pin keeps its no-re-expansion intent. New pins: funnel-level drive-form/mask/legacy tests plus tests/issue592_argv_translation_completeness.rs (context x position x existence matrix with real sed/tee, verbatim exemption probes with real grep -F/sed/find/env, legacy bypass regression, and a real git worktree add /d/new end-to-end asserting the worktree list location). cargo check -D warnings clean (windows + unix + macos targets), fmt clean, full cargo test --no-fail-fast failure set identical to fresh master fcf7be1 bidirectionally (41 pre-existing host-environment failures, zero new, zero lost). * fix(path): legacy-gate test takes the drive designator as a char (UTF-8 boundary hygiene)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
现象
同一个路径,内建能用、外部命令不能用:
cd /mnt/cpwd回显/mnt/cls /mnt/ccannot access '/mnt/c'cp/grep/cat/find…cd走内建filesystem_path_for_display->shell_path_to_windows(有/mnt分支);外部命令走 argv 漏斗,
/mnt/X被归进 verbatim 组原样丢给子进程。根因:
/mnt/X被归错了类niubash#164把 drive form 定义为 verbatim,前提是"子进程自己有 POSIX 层能解析它"。逐形态核对:/d/xnormalize_api_operand_w(src/utils/native_path.cppm)第 138–153 行,单字母盘符分支/cygdrive/d/x/d/...再走上分支/mnt/d/xis_separator(normalized[2]));/mnt/c的bytes[2] == 'n',判定失败winuxcmd 全仓搜
mnt只有 8 处命中,全在DOCS/和scripts/,源码路径解析层零命中。⇒
/mnt/X跟虚拟系统根(/usr/bin、/etc…)同类,属于"shell 必须自己翻"那一类。历史(
/mnt是何时、为何被关掉的)8956c23431bc/mnt/c能用07bbb81177fd/74638a989fe6#62)db404a6085ff/mnt/cfoo的 false positive → 说明当时还在翻5f7b1abf1dbd#164把/mnt/d/x写进 verbatim 清单 → 关闭#164的 commit message 原文:/mnt/d/x是"长得像"被顺带归类的——同一个 commit 对/usr/bin真的去 probe 了("probe 2026-10-02, WinuxCmd build-dev 1.0.3"),对/mnt没有。两条约束
niubash#62:"WinuxCmd (coreutils) must NOT change — the rule stays in the shell layer." → 只能修在 shell 侧。niubash#164:"要么都翻、要么都不翻,不应按命令名单切分" → 现在cd翻 /ls不翻,正是被禁止的切分。改动
windows_mnt_drive_argument():/mnt/X形状判定(/mnt/X或/mnt/X/...;/mnt/cfoo、/mnt/123是普通词),单一来源windows_external_absolute_argument_needs_translation里的内联判定收敛到它(消重)translated_virtual_system_root_argument纳入该形态 → applet / dispatcher / native exe 一律收到X:\.../d/x、/cygdrive/d/x保持 verbatim,字节未动后果排查
/mnt/cfoodb404a6085ff已修且有测试)/d/x、/cygdrive/d/xcfg!(windows)内#62的模式误伤/h/单字母容易偶然出现,/mnt/是完整词且只认单字母/mnt/d/...正是 WSL 下 GNU 的自然形态(rubash#329里 GNU 就写NVM_DIR="/mnt/d/…/nvm")测试
windows_mnt_drive_argument_translates_for_every_child:形状类、applet 收到的拼写(/mnt/c→C:\,/mnt/d/repo/x→D:\repo\x)、MSYS 形态仍 verbatimwindows_virtual_system_root_arguments_keep_option_b_shapes_verbatim:把/mnt/c移出 verbatim 清单(该断言编码的前提是错的)验证状态(如实说明)
cargo check --lib在 Linux 侧通过。测试体全部cfg(windows)门控,Linux 上不参与编译,需要在 Windows runner 上跑。这不是"已测过"。Closes unixwin/niubash#164 的遗留格。相关:unixwin/WinuxCmd#1145(
/d/...同族)。