aboutsummaryrefslogtreecommitdiff
path: root/git-annex.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-10-15 20:33:52 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-10-15 20:33:52 -0400
commita87f9b63077c8b93f4b2284d494c0081bd938f8d (patch)
treed56e424b73aecfca32f24b637fcc0dcc2050adce /git-annex.hs
parent10ff3282ee60cc41ad9d9ac71a99eea7053cebaa (diff)
Use haskell setenv library to clean up several ugly workarounds for inability to manipulate the environment on windows.
Didn't know that this library existed! This includes making git-annex not re-exec itself on start on windows, and making the test suite on Windows run tests without forking.
Diffstat (limited to 'git-annex.hs')
-rw-r--r--git-annex.hs39
1 files changed, 9 insertions, 30 deletions
diff --git a/git-annex.hs b/git-annex.hs
index f1af0eea5..f2005e13e 100644
--- a/git-annex.hs
+++ b/git-annex.hs
@@ -19,9 +19,6 @@ import qualified Test
#ifdef mingw32_HOST_OS
import Utility.UserInfo
import Utility.Env
-import Config.Files
-import System.Process
-import System.Exit
#endif
main :: IO ()
@@ -33,7 +30,9 @@ main = do
| isshell n = CmdLine.GitAnnexShell.run ps
| otherwise =
#ifdef mingw32_HOST_OS
- winEnv gitannex ps
+ do
+ winEnv
+ gitannex ps
#else
gitannex ps
#endif
@@ -49,37 +48,17 @@ main = do
#ifdef mingw32_HOST_OS
{- On Windows, if HOME is not set, probe it and set it.
- - This is a workaround for some Cygwin commands needing HOME to be set,
- - and for there being no known way to set environment variables on
- - Windows, except by passing an environment in each call to a program.
- - While ugly, this workaround is easier than trying to ensure HOME is set
- - in all calls to the affected programs.
+ - This is a workaround for some Cygwin commands needing HOME to be set.
-
- If TZ is set, unset it.
- TZ being set can interfere with workarounds for Windows timezone
- horribleness, and prevents getCurrentTimeZone from seeing the system
- time zone.
- -
- - Due to Windows limitations, have to re-exec git-annex with the new
- - environment.
-}
-winEnv :: ([String] -> IO ()) -> [String] -> IO ()
-winEnv a ps = do
- e <- getEnvironment
+winEnv :: IO ()
+winEnv = do
home <- myHomeDir
- let e' = wantedenv e home
- if (e' /= e)
- then do
- cmd <- readProgramFile
- (_, _, _, pid) <- createProcess (proc cmd ps)
- { env = Just e' }
- exitWith =<< waitForProcess pid
- else a ps
- where
- wantedenv e home = delEntry "TZ" $ case lookup "HOME" e of
- Nothing -> e
- Just _ -> addEntries
- [ ("HOME", home)
- , ("CYGWIN", "nodosfilewarning")
- ] e
+ setEnv "HOME" home False
+ setEnv "CYGWIN" "nodosfilewarning" True
+ unsetEnv "TZ"
#endif