Repository navigation
fix(path): tmp_base_w skips POSIX-spelled TEMP/TMP — Git Bash circular mapping (Fixes #1769) - #1780
Merged
Merged
Conversation
…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.
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.
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.