diff options
author | Stephane Glondu <steph@glondu.net> | 2011-04-19 16:52:57 +0200 |
---|---|---|
committer | Stephane Glondu <steph@glondu.net> | 2011-04-19 16:52:57 +0200 |
commit | 7a24ebd7506f927a6493d065b8c9c297afd08db3 (patch) | |
tree | 3ee6d9c9aa5fc6cf6f793c1fb1a37c2307fd0287 /lib/system.ml | |
parent | 4b1c150e26881501db9aa944df6406150fc0670d (diff) | |
parent | aa33547c764a229e22d323ca213d46ea221b903e (diff) |
Merge commit 'upstream/8.3.pl2+dfsg'
Diffstat (limited to 'lib/system.ml')
-rw-r--r-- | lib/system.ml | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/system.ml b/lib/system.ml index 17d211f8..7744a79b 100644 --- a/lib/system.ml +++ b/lib/system.ml @@ -6,7 +6,7 @@ (* * GNU Lesser General Public License Version 2.1 *) (************************************************************************) -(* $Id: system.ml 13323 2010-07-24 15:57:30Z herbelin $ *) +(* $Id: system.ml 13750 2010-12-24 09:55:54Z letouzey $ *) open Pp open Util @@ -19,12 +19,21 @@ let safe_getenv_def var def = Sys.getenv var with Not_found -> warning ("Environment variable "^var^" not found: using '"^def^"' ."); - flush Pervasives.stdout; + flush_all (); def let getenv_else s dft = try Sys.getenv s with Not_found -> dft -let home = (safe_getenv_def "HOME" ".") +(* On win32, the home directory is probably not in $HOME, but in + some other environment variable *) + +let home = + try Sys.getenv "HOME" with Not_found -> + try (Sys.getenv "HOMEDRIVE")^(Sys.getenv "HOMEPATH") with Not_found -> + try Sys.getenv "USERPROFILE" with Not_found -> + warning ("Cannot determine user home directory, using '.' ."); + flush_all (); + "." let safe_getenv n = safe_getenv_def n ("$"^n) |