Skip to content

WIP: fix(path): drive root forms verbatim for every drive (niubash#779 R2 cleanup) - #2458

Merged
caomengxuan666 merged 2 commits into
masterfrom
fix/drive-root-verbatim-r2
Nov 1, 2026
Merged

caomengxuan666 merged 2 commits into
masterfrom
fix/drive-root-verbatim-r2

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Refs: unixwin/niubash#779 (issue closed as R0 / documented boundary by the owner's 2026-11-01 ruling; this PR is the separately approved R2 cleanup from the same verdict).

The change — exactly one guard

In src/executor/path.rs, external_argument_path's drive-form branch:

-            if drive != b'c' && normalized.len() <= 3 {
+            if normalized.len() <= 3 {
                 return arg.to_string();
             }
             if drive != b'c' && argv_dialect_legacy(env_vars) && !translated.exists() {

Drive c's root forms (/c, /c/) used to fall through the root-form guard and translate to C:\ while every other drive's root forms stayed verbatim. The niubash#779 experiment round (MATRIX/CORPUS/VERDICT, mechanised scoring) proved a root-form token is indistinguishable from a switch in the receiving program's grammar — /c is both the C-drive root spelling and cmd.exe's run-and-exit flag — and that unconditional translation (R1) and the existence gate (R3) score identically DEAD on the killing rows (cmd /c, xcopy /D, robocopy /E). The owner ruled root forms verbatim for all drives (R0) and approved deleting the drive-c exception as a cleanup (R2). The deletion also closes a live data corruption the verdict surfaced: a native tr '/c/' X received C:\ as its SET1 (tr is not one of the grammar-masked tools grep/sed/awk/find/basename/dirname).

The comment above the guard is reworded to match: the "explicit POSIX display-path spelling" claim now scopes to with-components forms, and the root-form paragraph records the #779 ruling. The Option B explanation below it is intact.

Hard-limit confirmations

  • The legacy-dialect existence-gate line (argv_dialect_legacy) is byte-identical — untouched.
  • With-components /X/... translation (Option B), virtual system roots, /mnt/X, /dev/null → nul, and the posix-aware / bridge / cmd child classes are unchanged in behavior. (/mnt/c → C:\ still happens — through the /mnt/X arm, not the root-form guard.)
  • Shell-side path resolution is a different funnel and is untouched: shell_path_to_windows("/c/") still maps to C:\ for the shell's own operands (cd /c/ etc.).
  • Spellings that still reach a drive root for a native child: /X/., /mnt/X/, and the native X:/ form.

Pins

New unit pin in src/executor/path.rs tests (extends the existing funnel pin family; no integration file — an end-to-end variant would need either the winuxcmd toolchain or would pin the verbatim-by-class cmd route instead of this funnel):

  • issue779_drive_root_forms_stay_verbatim_for_native_children (#[cfg(windows)], like all funnel pins): /c, /c/, /d, /d/, /C/ verbatim for a native child; overreach guards /c/Users → C:\Users and /d/x → D:\x still translate; the tr '/c/' X data case stays verbatim.

Pin hunt result: no existing test asserted a translated root form for a native/applet child, so no assertion was flipped. (The C:\ expectations elsewhere are the /mnt/c arm and shell_path_to_windows mapping tests — both out of scope and untouched. The one behavioral neighbor, drive_form_arguments_translate_for_the_posix_aware_child, already pins /d verbatim and /c/Windows translated; both still hold.)

Verification (Linux VM; the funnel is cfg!(windows), so Windows CI is the executing gate for the pin)

  • cargo check --target x86_64-pc-windows-msvc --tests — cannot run here (cc-rs needs a real MSVC cl.exe).
  • cargo check --target x86_64-pc-windows-gnu --tests — Finished (warnings only, all pre-existing in unrelated files). This compile-verifies the changed funnel and the new pin in the Windows configuration.
  • Scrubbed-fd harness: cargo test --lib executor::path → 9 passed / 0 failed (the module's cross-platform subset; its other ~90 tests are #[cfg(windows)] and run in Windows CI). cargo test --test issue592_argv_translation_completeness → 0 tests on Linux by that file's own #![cfg(windows)] design; it compiles, and its compile is covered by the windows-gnu check above.
  • rustfmt --check on the file: clean before and after. LF-only.

…9 R2)

The argv funnel's root-form guard exempted drive c: `/c` and `/c/`
fell through and were translated to `C:\` for native children while
every other drive's root forms stayed verbatim. A root-form token is
indistinguishable from a switch in the receiving program's grammar
(`/c` is both the C-drive root spelling and cmd.exe's run-and-exit
flag); the niubash#779 experiment round (owner ruling 2026-11-01)
killed every discriminating rule — unconditional translation and the
existence gate score identically on the killing rows — so root forms
stay verbatim for all drives (R0), and this change deletes the
drive-c exception (R2). It also closes a live data corruption: a
native `tr '/c/' X` received `C:\` as its SET1 (tr is not one of the
grammar-masked tools).

With-components `/X/...` translation (Option B, niubash#124(b)), the
legacy-dialect existence gate on the line below the guard, virtual
roots, /mnt/X and /dev/null -> nul are unchanged. Spellings that
still reach a drive root for a native child: `/X/.`, `/mnt/X/`,
`X:/`.

Pin: issue779_drive_root_forms_stay_verbatim_for_native_children —
root forms verbatim for native children, with-components forms still
translated (overreach guard), the tr data case. No existing test
asserted the old translated root form, so no assertion was flipped.

Refs: unixwin/niubash#779
@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 1, 2026 09:14
@caomengxuan666
caomengxuan666 merged commit 67b9c56 into master Nov 1, 2026
10 of 11 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/drive-root-verbatim-r2 branch November 2, 2026 01:10
SpookyWaste pushed a commit to SpookyWaste/rubash that referenced this pull request Nov 12, 2026
…tion (audit R1)

The README (EN+zh) and docs/platform-identity.md still taught the
pre-unixwin#748 model: "POSIX-layer children get argv verbatim" and "a native
tool gets a valid Win32 path for every operand". Current contract:
drive-form operands are translated by the engine funnel for every
child class (unixwin#592); native children receive Win32 spellings for
classified path-shaped operands, while the bare /, drive-root forms,
attached values and grammar-data operands cross verbatim (unixwin#748/unixwin#779,
R2 cleanup PR unixwin#2458). Both READMEs now defer to niubash
docs/src/windows-path-contract.md as the contract of record.

The frozen R2 rollback sentences (__RUBASH_ARGV_DIALECT=legacy) are
preserved verbatim; only the stale dialect claims around them moved.
SpookyWaste pushed a commit to SpookyWaste/rubash that referenced this pull request Nov 12, 2026
…#779 generation (audit R6)

The in-repo contract still presented the 2026-10-13 unixwin#592 model as the
latest state, including the L4 absolutism "never half of one argv
translated, half not". Updates: header names niubash
docs/src/windows-path-contract.md as the argv-dialect contract of
record; the L4 row and L4 detail bullets now carry the verbatim
classes (bare /, drive-root forms, attached values, grammar data)
that cross unchanged per unixwin#748/unixwin#779 (R2 cleanup PR unixwin#2458); the unixwin#592
section gains the 2026-11-01 correction note in the doc's own
annotation style; the audit ledger gains the unixwin#748/unixwin#779 entry.

The frozen R2 rollback clauses (__RUBASH_ARGV_DIALECT=legacy) are
byte-identical to master; only the stale dialect claims moved.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant