Skip to content

Commit 60048d2

Browse files
committed
mingw: Prepare the TMP environment variable for shell scripts
When shell scripts access a $TMP variable containing backslashes, they will be mistaken for escape characters. Let's not let that happen by converting them to forward slashes. This fixes t7800 with MSys2. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 562eeac commit 60048d2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

compat/mingw.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,6 +2233,18 @@ void mingw_startup()
22332233
environ[i] = xstrdup(to_free + 6);
22342234
free(to_free);
22352235
}
2236+
if (starts_with(environ[i], "TMP=")) {
2237+
/*
2238+
* Convert all dir separators to forward slashes,
2239+
* to help shell commands called from the Git
2240+
* executable (by not mistaking the dir separators
2241+
* for escape characters.
2242+
*/
2243+
char *p;
2244+
for (p = environ[i]; *p; p++)
2245+
if (*p == '\\')
2246+
*p = '/';
2247+
}
22362248
}
22372249
environ[i] = NULL;
22382250
free(buffer);

0 commit comments

Comments
 (0)