Skip to content

Commit 2acb3e7

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 7f9728d commit 2acb3e7

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
@@ -2226,6 +2226,18 @@ void mingw_startup()
22262226
environ[i] = xstrdup(to_free + 6);
22272227
free(to_free);
22282228
}
2229+
if (!strncasecmp(environ[i], "TMP=", 4)) {
2230+
/*
2231+
* Convert all dir separators to forward slashes,
2232+
* to help shell commands called from the Git
2233+
* executable (by not mistaking the dir separators
2234+
* for escape characters).
2235+
*/
2236+
char *p;
2237+
for (p = environ[i]; *p; p++)
2238+
if (*p == '\\')
2239+
*p = '/';
2240+
}
22292241
}
22302242
environ[i] = NULL;
22312243
free(buffer);

0 commit comments

Comments
 (0)