Commit 6a90f7d1 authored by Mikhail Glushenkov's avatar Mikhail Glushenkov
Browse files

Normalise the names of environment variables on Windows.

Thanks to Eugene Sukhodolin for the bug report.
parent 15af3b79
......@@ -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
......
{-# 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
......@@ -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)
......
......@@ -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 )
......
......@@ -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.
......
......@@ -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 )
......
......@@ -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 )
......
......@@ -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 )
......
......@@ -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 ((<.>), (</>))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment