Skip to content

Commit 242092f

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 7c7e3fc commit 242092f

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
@@ -2110,6 +2110,18 @@ void mingw_startup()
21102110
environ[i] = xstrdup(to_free + 6);
21112111
free(to_free);
21122112
}
2113+
if (!strncasecmp(environ[i], "TMP=", 4)) {
2114+
/*
2115+
* Convert all dir separators to forward slashes,
2116+
* to help shell commands called from the Git
2117+
* executable (by not mistaking the dir separators
2118+
* for escape characters.
2119+
*/
2120+
char *p;
2121+
for (p = environ[i]; *p; p++)
2122+
if (*p == '\\')
2123+
*p = '/';
2124+
}
21132125
}
21142126
environ[i] = NULL;
21152127
free(buffer);

0 commit comments

Comments
 (0)