From 95f12f2b8095f833e1133f4ffb147661640d7cb5 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 20 Feb 2015 15:41:20 +0000 Subject: [PATCH] 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 --- compat/mingw.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/compat/mingw.c b/compat/mingw.c index b04dad55e1..7cb8939d11 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -2226,6 +2226,18 @@ void mingw_startup() environ[i] = xstrdup(to_free + 6); free(to_free); } + if (!strncasecmp(environ[i], "TMP=", 4)) { + /* + * 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);