mingw: prepare the TMPDIR environment variable for shell scripts
When shell scripts access a $TMPDIR variable containing backslashes, they will be mistaken for escape characters. Let's not let that happen by converting them to forward slashes. This partially fixes t7800 with MSYS2. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
		
				
					committed by
					
						
						Junio C Hamano
					
				
			
			
				
	
			
			
			
						parent
						
							02e6edc082
						
					
				
				
					commit
					1fc7bf79e5
				
			@ -2046,13 +2046,28 @@ int xwcstoutf(char *utf, const wchar_t *wcs, size_t utflen)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static void setup_windows_environment()
 | 
					static void setup_windows_environment()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						char *tmp = getenv("TMPDIR");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* on Windows it is TMP and TEMP */
 | 
						/* on Windows it is TMP and TEMP */
 | 
				
			||||||
	if (!getenv("TMPDIR")) {
 | 
						if (!tmp) {
 | 
				
			||||||
		const char *tmp = getenv("TMP");
 | 
							if (!(tmp = getenv("TMP")))
 | 
				
			||||||
		if (!tmp)
 | 
					 | 
				
			||||||
			tmp = getenv("TEMP");
 | 
								tmp = getenv("TEMP");
 | 
				
			||||||
		if (tmp)
 | 
							if (tmp) {
 | 
				
			||||||
			setenv("TMPDIR", tmp, 1);
 | 
								setenv("TMPDIR", tmp, 1);
 | 
				
			||||||
 | 
								tmp = getenv("TMPDIR");
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (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).
 | 
				
			||||||
 | 
							 */
 | 
				
			||||||
 | 
							for (; *tmp; tmp++)
 | 
				
			||||||
 | 
								if (*tmp == '\\')
 | 
				
			||||||
 | 
									*tmp = '/';
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* simulate TERM to enable auto-color (see color.c) */
 | 
						/* simulate TERM to enable auto-color (see color.c) */
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user