@@ -2218,6 +2218,22 @@ int handle_long_path(wchar_t *path, int len, int max_path, int expand)
22182218 }
22192219}
22202220
2221+ static void setup_windows_environment ()
2222+ {
2223+ /* on Windows it is TMP and TEMP */
2224+ if (!getenv ("TMPDIR" )) {
2225+ const char * tmp = getenv ("TMP" );
2226+ if (!tmp )
2227+ tmp = getenv ("TEMP" );
2228+ if (tmp )
2229+ setenv ("TMPDIR" , tmp , 1 );
2230+ }
2231+
2232+ /* simulate TERM to enable auto-color (see color.c) */
2233+ if (!getenv ("TERM" ))
2234+ setenv ("TERM" , "cygwin" , 1 );
2235+ }
2236+
22212237/*
22222238 * Disable MSVCRT command line wildcard expansion (__getmainargs called from
22232239 * mingw startup code, see init.c in mingw runtime).
@@ -2314,19 +2330,7 @@ void mingw_startup()
23142330 qsort (environ , i , sizeof (char * ), compareenv );
23152331
23162332 /* fix Windows specific environment settings */
2317-
2318- /* on Windows it is TMP and TEMP */
2319- if (!mingw_getenv ("TMPDIR" )) {
2320- const char * tmp = mingw_getenv ("TMP" );
2321- if (!tmp )
2322- tmp = mingw_getenv ("TEMP" );
2323- if (tmp )
2324- setenv ("TMPDIR" , tmp , 1 );
2325- }
2326-
2327- /* simulate TERM to enable auto-color (see color.c) */
2328- if (!getenv ("TERM" ))
2329- setenv ("TERM" , "cygwin" , 1 );
2333+ setup_windows_environment ();
23302334
23312335 /*
23322336 * Avoid a segmentation fault when cURL tries to set the CHARSET
0 commit comments