Repository navigation
fix: canonicalize folds /cygdrive+/mnt like argv (#1246); look trailing-newline phantom entry (#1251); tree -o operand fold (#1254) - #1255
Conversation
…e argv boundary canonicalize_path_w (realpath, readlink -f/-e/-m, stat -L) folded only the single-letter MSYS drive form (#1231), so /cygdrive/e/... (#1145) and /mnt/e/... (#1172) stranded on the cwd - or mapped under the shell root - while stat/test -f/ls folded the same spelling at the argv boundary: "test -f said yes, realpath said no" (#1246, #850 family, confirmed by the #1245 review). The prefix recognition moves into fold_posix_drive_prefix_w (byte-identical conditions, single-sourced) and the resolver runs it before fold_drive_dialect_w, mirroring normalize_api_operand_w's fold sequence; normalize_api_operand_w calls the same helper so the two boundaries cannot drift. A prefix operand is native-dialect input exactly like a drive-form one: native spelling, never re-expressed as a shell-namespace path. Also lands the #1245 CR nits: a regression pin for the intended stat side effect (stat /usr/bin with a configured shell root resolves through the shell tree like ls/readlink -f) and the CHANGELOG entry #1245 did not carry. Caller-count wording per NIT-1 goes in the PR description (four callers of canonicalize_path_w; winux_fifo_pipe_name_w's inputs are pre-normalized, so the new fold is a no-op there). Closes #1246.
…ary entry
The read loop emitted an empty line for the text after the last '\n', so a
standard trailing-newline dictionary ("...charlie\ndelta\n") carried a ""
entry at the END of its sorted line array. "" sorts before every key, but
the binary search's midpoint can land on the phantom and push lower_bound
past the last real word: `look -f delt` printed nothing (#1251).
The final newline at EOF now contributes no entry, matching util-linux
look 2.39.3 (WSL oracle): `look -f delt` on "...delta\n" prints delta,
`look ''` over a trailing-newline dictionary prints every real word and no
trailing empty line, and a lone "\n" file is exactly one empty entry.
Empty lines in the middle of the dictionary keep working as real entries.
Closes #1251.
tree folded its read-side root operand through normalize_api_operand since #1236, but the -o file operand went to ofstream as raw text. Win32 resolves a leading "/e" against the CURRENT drive, so from a foreign cwd `tree -o /e/probe/out.txt` failed to open (or would have written a shadow "<cwd-drive>:\e\probe\out.txt") instead of writing on the named drive - the write-side blind spot of the #1230 sweep (#1248 CR n2). The output operand folds once through the same boundary as the root; the open-failure message keeps quoting the spelling as typed (#1234 split). Closes #1254.
Independent code review — verdict: APPROVEReviewed independently from my own worktrees — PR head Verified (all re-executed; fixture
|
Closes #1246. Closes #1251. Closes #1254.
Problem
Three follow-up defects, one per ticket:
canonicalize_path_w(the shared resolver behindrealpath,readlink -f/-e/-mandstat -L) folded only the single-letter MSYS drive form (realpath/readlink -f 裸盘符根 /x 形态静默拼接 cwd——canonicalize_path_w 共享入口缺盘符折叠 #1231). The/cygdrive/e/...(Per-command gaps resolving verbatim POSIX argv: cp/mv/ls(file,-d) fail on /d/... drive paths while cat/mktemp/ls(dir) resolve them (blocks niubash#124 Option B) #1145) and/mnt/e/...(feature: native 层解析 /mnt/X 形态(WSL 互操作路径;rubash#568 裁决实证全系无支持) #1172) prefixes — already folded at the argv boundary bynormalize_api_operand_w— stranded in the resolver: from a foreign cwdrealpath /cygdrive/e/probe/progreported ENOENT andrealpath -mprinted a<cwd>:\cygdrive\e\...walk (or, with a shell root configured, the verbatim/cygdrive/...shell-namespace spelling), whilestat/test -f/lson the same spelling answered for the realE:\file. Two commands, one operand, opposite answers — the [upstream-closed] Multicall binary fails to dispatch when invoked via fexecve/execveat(..., AT_EMPTY_PATH) — derives util name from binary (uutils#12552) #850 family ("test -f says yes, realpath says no"), confirmed as an out-of-scope gap by the fix(native-path): fold the POSIX drive dialect in canonicalize_path_w (#1231) #1245 review.…charlie\ndelta\n) carried an""entry at the END of its sorted line array.""sorts before every key, but the binary search's midpoint can land on the phantom and push lower_bound past the last real word:look -f deltprinted nothing. Found during the fix(tree/namei/look): fold POSIX drive-dialect operands onto the named drive (#1236 #1237 #1242) #1248 look work, unrelated to the dialect.normalize_api_operand(tree 裸盘符根 /x 形态 GetFullPathNameW 误解析——影子目录存在时静默列错(cwd 盘符漂移) #1236) but handed the-ooutput operand toofstreamas raw text: from a foreign cwdtree -o /e/probe/out.txtfailed to open (Win32 resolved the leading/eagainst the cwd's drive) — the write-side blind spot of the df 裸盘符根参数(/d、/e)绕过盘符方言识别,cwd 盘符依赖误解析——疑似共享路径归一化盲区,需全命令扫描 #1230 sweep (fix(tree/namei/look): fold POSIX drive-dialect operands onto the named drive (#1236 #1237 #1242) #1248 CR n2).Fix
native_path.cppm: the cygdrive/mnt prefix recognition moves out ofnormalize_api_operand_wintofold_posix_drive_prefix_w(byte-identical conditions, single-sourced), andcanonicalize_path_wruns it beforefold_drive_dialect_w— mirroring the argv boundary's fold sequence (cygdrive Per-command gaps resolving verbatim POSIX argv: cp/mv/ls(file,-d) fail on /d/... drive paths while cat/mktemp/ls(dir) resolve them (blocks niubash#124 Option B) #1145 → /mnt feature: native 层解析 /mnt/X 形态(WSL 互操作路径;rubash#568 裁决实证全系无支持) #1172 → single-letter realpath/readlink -f 裸盘符根 /x 形态静默拼接 cwd——canonicalize_path_w 共享入口缺盘符折叠 #1231). A prefix operand is native-dialect input exactly like a drive-form one: it resolves to the native spelling and is never re-expressed as a shell-namespace path, with or without a configured shell root.normalize_api_operand_wnow calls the same helper, so the two boundaries cannot drift again.canonicalize_path_whas four callers, not three — realpath, readlink, stat (the broken surface) plus the internalwinux_fifo_pipe_name_w(FIFO pipe rendezvous naming), whose inputs arrive pre-normalized throughmake_api_path_operandin file_io, so the new prefix fold is a no-op there.stat /usr/binwith a shell root configured resolves through the shell tree like ls/readlink -f, instead of ENOENT) and the CHANGELOG entries fix(native-path): fold the POSIX drive dialect in canonicalize_path_w (#1231) #1245 did not carry.look.cpp: the read loop stops emitting the post-final-newline segment (while (start < data.size())), so a trailing newline synthesizes no entry; middle empty lines keep their existing semantics. Oracle: util-linux look 2.39.3 (WSL) —look -f delton…delta\nprintsdelta;look ''over a trailing-newline dictionary prints every real word and no trailing empty; a lone\nfile is exactly ONE empty entry; middle empty lines are tolerated the same way. (GNU errors out on a zero-length file — pre-existing divergence, untouched.)tree.cpp: the-ooperand folds once throughnative_path::normalize_api_operandlike the read-side root; the open-failure message keeps quoting the spelling as typed (ln 裸盘符根 /x 形态被 std::filesystem::absolute 拼接到 cwd——链接解析盘符随 cwd 漂移 #1234 display/fold split).Verification (PS/cmd native argv; #1230 — the local "Git Bash" is Niubash with MSYS argv pre-translation, so it was never used as an oracle)
Oracles: PowerShell
Resolve-Path(Win32) + WSL GNU coreutils / util-linux look 2.39.3. Probe treeE:\probe-cr1246, cwdsC:\Users\cmxandD:\repo, shell root unset and set — red on a freshorigin/main(8c19d14) build, green on this branch (cr-1246-matrix-base.txtvscr-1246-matrix-pr.txt).#1246 — realpath/readlink -f × {/cygdrive/e, /mnt/e} × {2 cwds × 2 shell-root states}:
realpath /cygdrive/e/probe-cr1246/progE:\probe-cr1246\progrealpath /mnt/e/probe-cr1246/progE:\probe-cr1246\progreadlink -f /cygdrive/e/...//mnt/e/...E:\probe-cr1246\progrealpath -m /cygdrive/e/.../nope<cwd>:\cygdrive\e\...(stranded);/cygdrive/e/...verbatim with root setE:\probe-cr1246\nopein all four statesstat/test -f/lson the same spellingsrealpath -m /nodrive1246,/mntcc,/mnt/data1246/usr/bin,/etc,/dev/nullshell-ns surfacerealpath /mnt/e/probe-cr1246/progE:\probe-cr1246\progequivalent, three-way agreement#1251 — three-form dictionaries vs util-linux look:
-f delt…charlie\ndelta\n(trailing NL)deltadelta…charlie\ndelta(no trailing NL)deltadeltadeltaalpha\n\ncharlie\ndelta\n(middle empty)deltadeltalook ''over middle-empty dict\nfile,look ''#1254 —
tree -o /e/probe-cr1254/out.txt, both cwds:E:(readable, GNU-shaped summary)<cwd-drive>:\e\probe-cr1254\out.txtNew regressions: realpath 2, readlink 2, stat 2 (incl. the NIT-2
stat /usr/binshell-root pin), look 4, tree 2.ctest
Full suite via
scripts/build.py --skip-configure --run-tests(MSVC/Ninja/Debug) on the exact commit content: 3027/3035 passed; 8 failures are the disclosed #1245 flake family —TempDircreate_directory races under suite load (mktemp_p_cygdrive_dir_outputs_cygdrive_form,ptx.ptx_auto_reference,sed.substitute_basic,sha512sum.sha512sum_check_without_valid_lines_reports_error,stat.stat_shell_root_usr_bin_resolves_through_shell_tree, ...). Every one passes in isolation, x3 consecutive runs;mktemp_p_cygdrive_dir_outputs_cygdrive_formalso failed on the untouched8c19d14baseline during this session. None touch the changed surface (native_path resolver fold, look read loop, tree -o open).Out of scope / unchanged
realpathon a zero-length dictionary-style operand and GNU look's "Invalid argument" on an empty file (GNU errors, we exit 0) — pre-existing, unrelated to the phantom-entry defect.