Repository navigation
fix(ls): keep drive-root separator when a dot collapse lands on the root - #1863
Merged
Merged
Conversation
…he root Refs #1862 With the process cwd at a drive root, ls failed every relative operand: cannot access '.' (rc 2). The operand boundary absolutizes '.' against the root cwd as \?\C:\. and fs_win's trailing-dot cleanup strips it to the bare drive spelling \?\C:, which the attribute probes reject (C: is drive-relative). lex_collapse only preserved the root separator when the input arrived with one, so any '.'/'..' collapse landing exactly on a drive root emitted the bare spelling. Fix: in lex_collapse, a collapse landing on a bare drive component keeps the root separator, the same rule root_trailing already applied to separator-carrying inputs. One mechanism, no operand special cases. Pins (rust2, windows): lex_collapse never emits a bare drive root; ls_cmd with Ctx cwd at a drive root lists it for no-operand, '.', '..' and the explicit root spelling (identical output); plain-dir control. Fail-first on master: 2 red / control green; fixed: full winux-cmds suite 1070 passed on X299.
This was referenced Nov 23, 2026
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.
Refs #1862
UNVERIFIED-BY-CAPTAIN — lane H delivery, code only.
Defect
With the process cwd at a drive root (
C:\,F:\), every relative ls operand failed:Non-root directories and the explicit
C:\spelling worked. Reproduced on master (3aaee819) with the rust2 driver under plain cmd (no niu): C:\ and F:\ roots, no-operand /./..all rc=2; control cwdC:\Usersfine.Root cause
One path, three steps (all in the ls operand boundary):
fs_win::imp::api_pathabsolutizes.against the root cwd to\\?\C:\., then its trailing-dot cleanup strips the final\.and hands back the bare drive spelling\\?\C:.C:is the drive-RELATIVE spelling (that drive's current directory), and\\?\C:is rejected by the attribute probes — thelex_collapseheader comment already records this.ls::lex_collapsepreserved the root separator only when the input arrived carrying one (root_trailing:C:\staysC:\). A collapse that lands on the root —C:\.,C:\..,C:\dir\.., or the bareC:from step 1 — fell through and emittedC:.Fix
Single mechanism, in
lex_collapse(the one collapse every ls probe/enumerate path goes through): a collapse whose result is a bare drive component keeps the root separator, extending the existingroot_trailingrule from "input carried the separator" to "result is the root". No operand special cases, no new path, no second normalization.本 PR 删除了什么
Nothing deleted. The change widens one existing condition in
lex_collapse(the separator-preservation rule) to cover the landing shape; it adds no mechanism, shim, or alternative path — the old behavior (emit bareC:) was not a feature any caller could rely on, since the probes reject that spelling outright.Regression pins (rust2,
cargo test -p winux-cmds, windows)New
ls::testsmodule inrust2/crates/winux-cmds/src/ls.rs:lex_collapse_never_emits_a_bare_drive_root—\\?\C:,\\?\C:\.,\\?\C:\..,\\?\C:\Users\..,\\?\F:\.all collapse to the rooted spelling; non-root collapses unchanged.drive_root_cwd_lists_the_root—ls_cmdwith Ctx cwd pinned to a real drive root: no operand,.,.., and the explicit root spelling all rc=0 with identical listings.dot_operands_in_a_plain_directory_still_list— non-root control.Fail-first (X299, master + pins only): 2 failed / control passed —
left: "\\\\?\\C:"vsright: "\\\\?\\C:\\", and rc 2cannot access '.'end-to-end. Fixed: full winux-cmds lib suite 1070 passed, 0 failed.X299 live check (driver built from this tree, plain cmd, process cwd at root): C:\ no-operand /
./../C:\/C:/all rc=0, and the no-operand,.andC:\outputs are byte-identical (30 lines); F:\ no-operand /.rc=0;C:\Userscontrol unchanged.Net lines
1 file changed:
rust2/crates/winux-cmds/src/ls.rs+105 / −1 (net +104): the fix itself is +11 / −1 aroundlex_collapse; the rest is the new pin module. No user-visible text changes (no i18n impact). No workflow changes — the CMake 4.4.5 pin form is untouched.