Skip to content

fix(path): tmp_base_w skips POSIX-spelled TEMP/TMP — Git Bash circular mapping (Fixes #1769) - #1780

Merged
caomengxuan666 merged 2 commits into
mainfrom
fix/tmp-base-w-msys-guard
Nov 16, 2026
Merged

caomengxuan666 merged 2 commits into
mainfrom
fix/tmp-base-w-msys-guard

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Mirrors the rust2-side fix (winux-core path.rs tmp_base): under a Git Bash parent, TEMP/TMP arrive as the MSYS form '/tmp' — tmp_base_w trusted it verbatim, so /tmp resolved circularly to /tmp and temp-file commands failed.

POSIX-spelled candidates (leading '/') are skipped in the TMPDIR > TEMP > TMP priority walk; when every candidate is POSIX-spelled, GetTempPathW provides the Windows default per-user temp (it skips candidates that do not exist). Purity note documented (the last-resort arm reads process state on purpose).

Tests: native_path_unit_test +3. Verified: VS build green; native_path.* 3/3; related 103/103; Git Bash-parent repro rc 0 — was failure; full suite 4034/4040 (6 pre-existing env items, unrelated).

Fixes #1769.

…r mapping (#1769)

Under a Git Bash parent, TEMP/TMP arrive as the MSYS form '/tmp'
itself: tmp_base_w trusted the value verbatim, so /tmp resolved
circularly to /tmp and every temp-file command failed (same class as
the rust2 side's fix in winux-core path.rs tmp_base).

Mirrors the rust2 fix: POSIX-spelled candidates (leading '/') are
skipped in the TMPDIR > TEMP > TMP priority walk; when every
candidate is POSIX-spelled, GetTempPathW provides the Windows default
per-user temp (it skips candidates that do not exist, landing on
USERPROFILE). Purity note documented: the last-resort arm reads
process state on purpose.

Tests: native_path_unit_test +3 (MSYS-form env resolves to the real
per-user temp; native-form candidates unaffected; GetTempPathW arm
covered via the /tmp fold path).

Verified: VS build green; native_path.* 3/3; related group 103/103;
Git Bash-parent repro (TEMP=/tmp mktemp -p /tmp) rc 0 — was failure;
full suite 4034/4040 (6 pre-existing env items, unrelated).
…tes (#1792 mirror)

The #1769 skip threw away EVERY '/'-prefixed candidate — including the
MSYS drive spelling /c/Users/... that names a real Windows directory
through the dialect's existing folds. The rust2 twin's CI diagnostic
(#1792) pinned the exact shape: TMPDIR pointed at an existing harness
directory, mktemp created in the TEMP root instead.

tmp_base_w now folds /cygdrive/X, /mnt/X and /X onto the drive form
(the fold chain normalize_api_operand_w already owns, #1145 #1172
#1231) and adopts the candidate only when the folded path is an
existing directory; /tmp and /var/tmp stay unadopted because
shell_tree_map_w maps them THROUGH this function (the circular
mapping #1769 removed), and every other unusable value falls through,
keeping niubash#94's usable-per-user-temp fallback. The folds are
forward-declared at their definition scope for the candidate loop.

Verified: native_path 5/5 (3 existing pins unchanged + adopt + fall-
through mirrors), winuxcmd-tests builds clean under vcvars.
@caomengxuan666
caomengxuan666 merged commit 7cf7bde into main Nov 16, 2026
22 of 28 checks passed
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.

[bug] 1.x C++ tmp_base_w 的 /tmp 解析在 Git Bash 父进程下循环映射(TEMP=/tmp → /tmp)

1 participant