Skip to content

Commit

Permalink
mingw: Prepare the TMP environment variable for shell scripts
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
dscho committed Feb 22, 2015
1 parent 562eeac commit 60048d2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions compat/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -2233,6 +2233,18 @@ void mingw_startup()
environ[i] = xstrdup(to_free + 6);
free(to_free);
}
if (starts_with(environ[i], "TMP=")) {
/*
* Convert all dir separators to forward slashes,
* to help shell commands called from the Git
* executable (by not mistaking the dir separators
* for escape characters.
*/
char *p;
for (p = environ[i]; *p; p++)
if (*p == '\\')
*p = '/';
}
}
environ[i] = NULL;
free(buffer);
Expand Down

0 comments on commit 60048d2

Please sign in to comment.