Merge branch 'kb/mingw-set-home'
Windows port update. * kb/mingw-set-home: mingw: initialize HOME on startup
This commit is contained in:
commit
fc613d2d6e
@ -2333,6 +2333,30 @@ static void setup_windows_environment(void)
|
|||||||
/* simulate TERM to enable auto-color (see color.c) */
|
/* simulate TERM to enable auto-color (see color.c) */
|
||||||
if (!getenv("TERM"))
|
if (!getenv("TERM"))
|
||||||
setenv("TERM", "cygwin", 1);
|
setenv("TERM", "cygwin", 1);
|
||||||
|
|
||||||
|
/* calculate HOME if not set */
|
||||||
|
if (!getenv("HOME")) {
|
||||||
|
/*
|
||||||
|
* try $HOMEDRIVE$HOMEPATH - the home share may be a network
|
||||||
|
* location, thus also check if the path exists (i.e. is not
|
||||||
|
* disconnected)
|
||||||
|
*/
|
||||||
|
if ((tmp = getenv("HOMEDRIVE"))) {
|
||||||
|
struct strbuf buf = STRBUF_INIT;
|
||||||
|
strbuf_addstr(&buf, tmp);
|
||||||
|
if ((tmp = getenv("HOMEPATH"))) {
|
||||||
|
strbuf_addstr(&buf, tmp);
|
||||||
|
if (is_directory(buf.buf))
|
||||||
|
setenv("HOME", buf.buf, 1);
|
||||||
|
else
|
||||||
|
tmp = NULL; /* use $USERPROFILE */
|
||||||
|
}
|
||||||
|
strbuf_release(&buf);
|
||||||
|
}
|
||||||
|
/* use $USERPROFILE if the home share is not available */
|
||||||
|
if (!tmp && (tmp = getenv("USERPROFILE")))
|
||||||
|
setenv("HOME", tmp, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(_MSC_VER)
|
#if !defined(_MSC_VER)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user