Repository navigation
fix(paths): resolve bare MSYS drive-root operands through the shared argv boundary (#1230) - #1274
Conversation
…argv boundary (#1230) A bare drive root ("/e", "/e/") bypassed the drive-dialect recognizer in every command that touched the filesystem outside the shared native_path boundary: the raw operand decayed to a cwd-drive-relative path, so resolution depended on the caller's drive. Two shapes were found in the full-command scan: - resolution miss: raw operands reached ifstream/CreateFileW/ GetNamedSecurityInfoW/probes directly and silently read, wrote or queried <cwd>:\e (strings, xxd, tsort, hmac256, expand, unexpand, column, csplit, xargs -a, hostname -F, getfacl, stty -F, env -C, chroot, sync, sort -o/-T, diff list_directory, grep operand probes, mktemp's private dialect fold, df's operand loop) - classification miss: the open was normalized but the errno-reason probe ran on the raw text, producing cwd-dependent diagnostics (head, tail, sort, nl, fmt, fold, comm, join, paste, cut and the *sum family via portable_digest::open_failure_reason) Shared fixes: glob_expand folds the pattern once at entry (every "/e/*" caller), digest's open_failure_reason probes the resolved spelling, mktemp's recognizer accepts bare /x and /cygdrive/x roots. df keeps the operand spelling for diagnostics and the "file" field while filesystem calls use the normalized form. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Review: df fix + scan verified, one blocking gap found (sort
|
…anup (#1230) The drive-root operand fix left sort -T half-normalized: the validation probe folded "/e/..." onto the named volume while the spill-chunk path kept the raw spelling. create_binary_file then wrote every 8 MB chunk onto the hinted drive root, and the final std::filesystem::remove resolved "\e\..." against the cwd drive - a silent no-op that leaked each chunk. Fold the hint through normalize_api_operand at temp_dir construction and again at the remove call so creation, reopen, and cleanup share one resolved spelling. New regression drives "-T /d/..." through the external path and asserts no winuxcmd-sort-*.tmp survives. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Rework: sort
|
终审通过:merge e2504eb → main
|
…1276) (#1278) The -f/--prefix operand feeds each derived output filename, which the bare ofstream resolved literally: a dialect spelling like "/e/xx-" was opened relative to the cwd drive instead of the named drive. Normalize the filename once at materialization so the ofstream and cleanup's remove share one resolved spelling - the same pattern as the sort -T fix in #1274. Regression test: "-f /d/..." through the external path asserts the segments land in the named directory. Fixes #1276. Generated with [Devin](https://devin.ai) Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…ary (#1277) env --file opened its operand with a raw ifstream, so MSYS drive-dialect spellings ("/e/...") decayed to a cwd-drive-relative path and missed the named file - the same blind spot #1274 closed for sort -T. read_env_file now resolves the operand once through native_path::normalize_api_operand: the ifstream and the is_directory classification probe run on the native spelling while diagnostics keep the caller's text. Regression test: env -f /x/... through the external path loads the file and prints its assignments (verified failing before the fix with "cannot read env file '/c/...': No such file or directory"). Fixes #1275. Generated with [Devin](https://devin.ai) Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Summary
Fixes #1230 — bare MSYS drive-root operands (
/x,/x/) bypassed thedrive-dialect recognizer in every command that resolved its operand
outside the shared
native_pathboundary: the raw/xdecayed to acwd-drive-relative path (
<cwd>:\x), so results depended on which drivethe caller stood on.
Two bug shapes were found and fixed:
(
ifstream/CreateFileW/GetNamedSecurityInfoW/exists/…) verbatim,so
/esilently read, wrote or queriedD:\ewhen cwd sat onD:.Confirmed live:
strings/xxd/tsort/hmac256/expand/unexpand/column/xargs -a/stty -F/sync/getfacl/mktemp -p/env -Calloperated on the wrong drive when
<cwd>:\eexisted.the errno-reason probe (
std::filesystem::status,attributes_w,is_directory,GetFileAttributesW) ran on the raw operand, producingcwd-dependent diagnostics (
No such filevsIs a directoryvsPermission deniedfor the same operand).Fixes
df: operand loop now routes every positional throughnative_path::make_api_path_operand; stat/volume calls use thenormalized spelling, diagnostics and the
filefield keep the operandas typed.
utils:wildcard:glob_expandfolds the pattern throughnormalize_api_operand_wonce at entry — every*-expansion(
/e/*→E:\*) now enumerates the named drive.utils:digest:open_failure_reasonprobes the resolved spelling —one fix covers md5sum/sha1sum/sha224sum/sha384sum/sha256sum/sha512sum/
b2sum/cksum/sum,
dircolorsand grep's reason text.mktemp: its private drive-dialect recognizer had the same root-formblind spot (
size() >= 3rejected bare/xand/cygdrive/x).strings, xxd (in+out), tsort, csplit, expand, unexpand, column,
hmac256, xargs
-a, hostname-F, getfacl, stty-F, env-C,chroot, sync, sort (
-o,-T, error probe), diff (list_directory),grep (operand probes + recursive walk seed).
nl, fmt, fold, comm, join, paste, cut, column, expand, unexpand,
hmac256, xargs, plus the whole
*sumfamily via the digest fix.Regression
tests/unit/df:df /xanddf /x/report the named volume from aforeign-drive cwd (mirrors the #1231 stat dialect tests).
Full-command scan report
Probe matrix:
<cmd> /evs<cmd> E:/(E: existing dir,C:\e/D:\eabsent) plus a
D:\e-file cross-check from cwdD:(silentwrong-drive detection). Static side: every
ctx.positionals/option pathoperand audited for whether it reaches an OS call without
native_path::normalization.native_path/file_io)childproc::normalize_entryalready folds/x)cygpath -w /eprintsE:instead ofE:\(drive-relative vs root spelling) — separate formatting bug, not the dialect blind spot.hexdump/revreport ENOENT-style text for directory operands (resolve correctly; GNU-fidelity gap).updatedb --localpaths,wpm,cpio -Fuse their own path layers — flagged for follow-up audit, not confirmed affected.Test plan
df /e,df /e/,df /c(foreign cwd) report the named volumestrings/xxd/hmac256/expand/xargs -a/stty -F/sync/getfacl/mktemp -p/env -Cwith aD:\edecoy file no longer read/query the decoygrep /e,diff -q /e /e,sort /e,head /e,nl /e,md5sum /ereport E:\ (Is a directory), not ENOENTwinuxcmd-testsdf suite (new dialect-root tests)Generated with Devin