[commit: packages/Cabal] ghc-head: Normalise the names of environment variables on Windows. (6a90f7d)

git at git.haskell.org git at git.haskell.org
Mon Aug 26 23:30:25 CEST 2013


Repository : ssh://git@git.haskell.org/Cabal

On branch  : ghc-head
Link       : http://git.haskell.org/?p=packages/Cabal.git;a=commit;h=6a90f7d146813ca81d58e74633717050a7e417e4

>---------------------------------------------------------------

commit 6a90f7d146813ca81d58e74633717050a7e417e4
Author: Mikhail Glushenkov <mikhail.glushenkov at gmail.com>
Date:   Fri Aug 23 05:52:44 2013 +0200

    Normalise the names of environment variables on Windows.
    
    Thanks to Eugene Sukhodolin for the bug report.


>---------------------------------------------------------------

6a90f7d146813ca81d58e74633717050a7e417e4
 Cabal/Cabal.cabal                                  |    1 +
 Cabal/Distribution/Compat/Environment.hs           |   20 ++++++++++++++++++++
 Cabal/Distribution/Simple.hs                       |    3 ++-
 Cabal/Distribution/Simple/Program/Find.hs          |    2 +-
 Cabal/Distribution/Simple/Program/Run.hs           |    2 +-
 Cabal/Distribution/Simple/Test.hs                  |    2 +-
 cabal-install/Distribution/Client/Config.hs        |    2 +-
 .../Distribution/Client/Init/Heuristics.hs         |    2 +-
 cabal-install/Distribution/Client/Run.hs           |    2 +-
 9 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/Cabal/Cabal.cabal b/Cabal/Cabal.cabal
index 42731fd..8c820f4 100644
--- a/Cabal/Cabal.cabal
+++ b/Cabal/Cabal.cabal
@@ -140,6 +140,7 @@ library
   ghc-options: -Wall -fno-ignore-asserts -fwarn-tabs
 
   exposed-modules:
+    Distribution.Compat.Environment
     Distribution.Compat.ReadP
     Distribution.Compiler
     Distribution.InstalledPackageInfo
diff --git a/Cabal/Distribution/Compat/Environment.hs b/Cabal/Distribution/Compat/Environment.hs
new file mode 100644
index 0000000..5e0255d
--- /dev/null
+++ b/Cabal/Distribution/Compat/Environment.hs
@@ -0,0 +1,20 @@
+{-# LANGUAGE CPP #-}
+{-# OPTIONS_HADDOCK hide #-}
+
+module Distribution.Compat.Environment (getEnvironment)
+       where
+
+import qualified System.Environment as System
+
+getEnvironment :: IO [(String, String)]
+#ifdef mingw32_HOST_OS
+-- On Windows, the names of environment variables are case-insensitive, but are
+-- often given in mixed-case (e.g. "PATH" is "Path"), so we have to normalise
+-- them.
+getEnvironment = fmap upcaseVars System.getEnvironment
+  where
+    upcaseVars = map upcaseVar
+    upcaseVar (var, val) = (map Char.toUpper var, val)
+#else
+getEnvironment = System.getEnvironment
+#endif
diff --git a/Cabal/Distribution/Simple.hs b/Cabal/Distribution/Simple.hs
index d9fc611..9d8a65b 100644
--- a/Cabal/Distribution/Simple.hs
+++ b/Cabal/Distribution/Simple.hs
@@ -131,12 +131,13 @@ import Distribution.Text
          ( display )
 
 -- Base
-import System.Environment(getArgs, getProgName, getEnvironment)
+import System.Environment(getArgs, getProgName)
 import System.Directory(removeFile, doesFileExist,
                         doesDirectoryExist, removeDirectoryRecursive)
 import System.Exit
 import System.IO.Error   (isDoesNotExistError)
 import Control.Exception (throwIO)
+import Distribution.Compat.Environment (getEnvironment)
 import Distribution.Compat.Exception (catchIO)
 
 import Control.Monad   (when)
diff --git a/Cabal/Distribution/Simple/Program/Find.hs b/Cabal/Distribution/Simple/Program/Find.hs
index ac97939..fc7e11c 100644
--- a/Cabal/Distribution/Simple/Program/Find.hs
+++ b/Cabal/Distribution/Simple/Program/Find.hs
@@ -36,7 +36,7 @@ import Distribution.System
          ( OS(..), buildOS )
 import System.Directory
          ( findExecutable, doesFileExist, Permissions(..), getPermissions )
-import System.Environment
+import Distribution.Compat.Environment
          ( getEnvironment )
 import System.FilePath
          ( (</>), (<.>), splitSearchPath, searchPathSeparator )
diff --git a/Cabal/Distribution/Simple/Program/Run.hs b/Cabal/Distribution/Simple/Program/Run.hs
index 6229bab..5268be6 100644
--- a/Cabal/Distribution/Simple/Program/Run.hs
+++ b/Cabal/Distribution/Simple/Program/Run.hs
@@ -38,7 +38,7 @@ import Control.Monad
          ( when )
 import System.Exit
          ( ExitCode(..), exitWith )
-import System.Environment
+import Distribution.Compat.Environment
          ( getEnvironment )
 
 -- | Represents a specific invocation of a specific program.
diff --git a/Cabal/Distribution/Simple/Test.hs b/Cabal/Distribution/Simple/Test.hs
index 900cd9c..3fade9b 100644
--- a/Cabal/Distribution/Simple/Test.hs
+++ b/Cabal/Distribution/Simple/Test.hs
@@ -87,7 +87,7 @@ import System.Directory
     ( createDirectoryIfMissing, doesDirectoryExist, doesFileExist
     , getCurrentDirectory, getDirectoryContents, removeDirectoryRecursive
     , removeFile, setCurrentDirectory )
-import System.Environment ( getEnvironment )
+import Distribution.Compat.Environment ( getEnvironment )
 import System.Exit ( ExitCode(..), exitFailure, exitWith )
 import System.FilePath ( (</>), (<.>) )
 import System.IO ( hClose, IOMode(..), openFile )
diff --git a/cabal-install/Distribution/Client/Config.hs b/cabal-install/Distribution/Client/Config.hs
index 772ea70..12ee5f0 100644
--- a/cabal-install/Distribution/Client/Config.hs
+++ b/cabal-install/Distribution/Client/Config.hs
@@ -100,7 +100,7 @@ import Network.URI
          ( URI(..), URIAuth(..) )
 import System.FilePath
          ( (<.>), (</>), takeDirectory )
-import System.Environment
+import Distribution.Compat.Environment
          ( getEnvironment )
 import System.IO.Error
          ( isDoesNotExistError )
diff --git a/cabal-install/Distribution/Client/Init/Heuristics.hs b/cabal-install/Distribution/Client/Init/Heuristics.hs
index 37c5882..ccd460d 100644
--- a/cabal-install/Distribution/Client/Init/Heuristics.hs
+++ b/cabal-install/Distribution/Client/Init/Heuristics.hs
@@ -43,7 +43,7 @@ import Data.Monoid ( mempty, mconcat )
 import qualified Data.Set as Set ( fromList, toList )
 import System.Directory ( getDirectoryContents,
                           doesDirectoryExist, doesFileExist, getHomeDirectory, )
-import System.Environment ( getEnvironment )
+import Distribution.Compat.Environment ( getEnvironment )
 import System.FilePath ( takeExtension, takeBaseName, dropExtension,
                          (</>), (<.>), splitDirectories, makeRelative )
 import System.Process ( readProcessWithExitCode )
diff --git a/cabal-install/Distribution/Client/Run.hs b/cabal-install/Distribution/Client/Run.hs
index 4a79e8b..a36546c 100644
--- a/cabal-install/Distribution/Client/Run.hs
+++ b/cabal-install/Distribution/Client/Run.hs
@@ -28,7 +28,7 @@ import Distribution.Verbosity                (Verbosity)
 import Data.Functor                          ((<$>))
 import Data.List                             (find)
 import System.Directory                      (getCurrentDirectory)
-import System.Environment                    (getEnvironment)
+import Distribution.Compat.Environment       (getEnvironment)
 import System.FilePath                       ((<.>), (</>))
 
 





More information about the ghc-commits mailing list