Repository navigation
fix(mkdir): anchor drive-absolute operands at the drive root in the -p walk (#1870) - #1875
Conversation
Fail-first pins for the drive-absolute -p face: D1 same-drive slash form (tree must land at the absolute target, not under the cwd), D2 backslash form (parents must be created, -v prefixes keep the operand spelling), cross-drive D1b/D2c guards (self-skipping without a second writable drive), the POSIX drive-form fold guard, and the no-parents single-create guard. No production code changes.
…p walk (#1870) create_parents started every non-folded walk at the cwd and split only on '/': a same-drive 'D:/a/b/c' re-joined its 'D:' component onto the cwd, the join dropped the root, and Win32 resolved the result against the per-drive cwd — the tree landed under the caller's cwd, the target was never created, rc 0 (D1). The backslash spelling 'D:\a\b\c' arrived as one component, so -p created no parents and the leaf create failed ENOENT (D2). A drive-absolute fs_name now takes the anchored decomposition the folded forms already used (drive root + both-separator split), whether or not a fold claimed it. Display prefixes are sliced from the operand text at its component ends instead of re-joined, so -v and diagnostics name each created directory exactly as spelled (backslash operands keep their backslashes). Bare 'D:' and drive-relative 'D:name' keep their per-drive-cwd reading; the folded, POSIX-rooted and relative walks are unchanged.
|
CAPTAIN-VERIFY — merging. Reviewed head Fail-first: 3 reds with signatures matching the field report verbatim (including the shadow tree photographed under the test process's cwd), guards green before and after. Host matrix 22/22 on a real Windows host; PR CI 28 pass / 4 skipping / 0 fail. The local The #1874 separation argument in the PR is accepted: different layer, a live C++ twin with its own pin baseline, and a different regression surface — it proceeds as its own PR (#1876), not folded into this one. |
Refs #1870. Also carries the #1101 acceptance the captain promised on that issue (see Verification). UNVERIFIED-BY-CAPTAIN — lane code + host evidence only; not self-merged.
Defect (as filed, reproduced on v1.2.3 and on the pre-fix branch head)
mkdir -pmishandled drive-absolute operands in both spellings:D:/a/b/cwith the cwd on D:: rc=0, the target is never created, and the tree silently lands under the caller's cwd.D:\a\b\c:-pcreates no parents at all; the leaf create fails ENOENT unless every parent already exists.Mechanism, in
create_parents(rust2/crates/winux-cmds/src/mkdir.rs): every non-folded walk started at the cwd and split only on/. For D1 the walk re-joined theD:component onto the cwd — the join drops the root and Win32 resolves the result against the per-drive cwd. For D2 the whole backslash spelling arrived as a single component, so the walk made exactly one create attempt on the full path.Fix (one point, in the walk)
A drive-absolute
fs_name(X:+ separator) now takes the anchored decomposition the folded forms already used — root = the drive root, components split on both separators via thePathparent chain — whether or not a fold claimed the operand. The fold chain itself is untouched:prepare_operandstill returns these spellings unchanged, and they were never the fold's to claim.Display prefixes are now sliced from the operand text at its component ends instead of re-joined, so
-vlines and diagnostics name each created directory exactly as spelled (a backslash operand keeps its backslashes:mkdir: created directory 'D:\wt\a\b').Unchanged on purpose: bare
D:and drive-relativeD:namekeep their per-drive-cwd reading; the folded (/e/Data), POSIX-rooted, and relative walks behave as before (guards pin this).What this PR deletes
-pwalk (the D1/D2 mechanism itself).shown_comps[..=end].join("/")plus theabsolute_shownspecial case) — replaced by operand-sliced prefixes.let _ = &mut acc;leftover in the relative branch.Net-line accounting
One file (
rust2/crates/winux-cmds/src/mkdir.rs), +213/−35 total: pins +146/−0, production +67/−35. No new messages, no user-visible text changes (diagnostics reuse the existing reporting paths; only the path spelling inside them is now operand-faithful) — no I18N catalog impact.C++ twin review (per the lane brief)
Reviewed, no such face on the C++ side, no C++ change in this PR:
src/commands/mkdir.cppis a registration shell since [2.0 长线] 命令库化:显式 IO 的库形态命令集(Rust 重写候选)与机械替换路线 #1488 — the semantics live in rust2mkdir_cmd; there is no C++-pwalk to twin the defect.fold_carrier_colons_w/normalize_api_operand_w(src/utils/native_path.cppm) pass drive-absolute spellings through unchanged, which is correct: the defect was never in the fold, it was in the walk that consumed the folded operand.Boundary with #1874 (captain asked this lane to evaluate bundling)
Evaluated: separate mechanisms, not bundled — full evidence in the lane report. In one line: the anchoring lives in one applet's walk decomposition, while #1874's missing carrier encoding lives in the shared
fold_carrier_colons(both operand chains, every applet) whose final-component scope is a pinned contract with its live C++ twin. Confirmed empirically on this branch's build: after this fix,ls x:y/zandmkdir -p q:w/c(colon in a non-final component) still fail while the U+F03A spellings work — that face survives this PR by design and belongs to #1874's own lane.Verification (devin-windows, Windows Server 2022)
Vehicle note: the host has no VS/MSVC linker, so tests and the acceptance matrix ran on the
1.99.1-x86_64-pc-windows-gnutoolchain throughwinuxcmd-driver— the samewinux_cmds::dispatchthe shipped exe calls (the #1873 precedent). Judgment surface is the library logic; the MSVC shipping build is for CI.cannot create directory '...': No such file or directory, rc 1. Guards green pre-fix, as designed.df::tests::type_filtersA/B-reproduced on pristine3940c00(host-environment leftover, unrelated); winux-core lib 34/34.cargo fmt --checkclean for the touched file.-vbackslash prefixes, relative-path regression, no--pstill rc=1, plus the [bug] applets fail on literal-colon operands: canon layer does not carrier-encode operand path components #1874 separation spot-checks above.mkdir.exetemporarily replaced by a forwarder to this branch's driver, restored afterwards): 12/12 — the reporter's three named shapes stay clean (rc 0, targets built, no strayD+U+F03A in the cwd), and the two explicit-exe shapes that used to collide with D2 (/d/...from C:) and D1 (D:/...from D:) now create at the target with the cwd untouched.