@@ -2209,6 +2209,22 @@ int handle_long_path(wchar_t *path, int len, int max_path, int expand)
22092209 }
22102210}
22112211
2212+ static void setup_windows_environment ()
2213+ {
2214+ /* on Windows it is TMP and TEMP */
2215+ if (!getenv ("TMPDIR" )) {
2216+ const char * tmp = getenv ("TMP" );
2217+ if (!tmp )
2218+ tmp = getenv ("TEMP" );
2219+ if (tmp )
2220+ setenv ("TMPDIR" , tmp , 1 );
2221+ }
2222+
2223+ /* simulate TERM to enable auto-color (see color.c) */
2224+ if (!getenv ("TERM" ))
2225+ setenv ("TERM" , "cygwin" , 1 );
2226+ }
2227+
22122228/*
22132229 * Disable MSVCRT command line wildcard expansion (__getmainargs called from
22142230 * mingw startup code, see init.c in mingw runtime).
@@ -2305,19 +2321,7 @@ void mingw_startup()
23052321 qsort (environ , i , sizeof (char * ), compareenv );
23062322
23072323 /* fix Windows specific environment settings */
2308-
2309- /* on Windows it is TMP and TEMP */
2310- if (!mingw_getenv ("TMPDIR" )) {
2311- const char * tmp = mingw_getenv ("TMP" );
2312- if (!tmp )
2313- tmp = mingw_getenv ("TEMP" );
2314- if (tmp )
2315- setenv ("TMPDIR" , tmp , 1 );
2316- }
2317-
2318- /* simulate TERM to enable auto-color (see color.c) */
2319- if (!getenv ("TERM" ))
2320- setenv ("TERM" , "cygwin" , 1 );
2324+ setup_windows_environment ();
23212325
23222326 /*
23232327 * Avoid a segmentation fault when cURL tries to set the CHARSET
0 commit comments