2017-12-31 20:08:31 +00:00
|
|
|
{- portable environment variables, without any dependencies
|
|
|
|
-
|
|
|
|
- Copyright 2013 Joey Hess <id@joeyh.name>
|
|
|
|
-
|
|
|
|
- License: BSD-2-clause
|
|
|
|
-}
|
|
|
|
|
|
|
|
{-# OPTIONS_GHC -fno-warn-tabs #-}
|
|
|
|
|
2019-11-21 19:38:06 +00:00
|
|
|
module Utility.Env.Basic (
|
|
|
|
getEnv,
|
|
|
|
getEnvDefault,
|
|
|
|
) where
|
2017-12-31 20:08:31 +00:00
|
|
|
|
|
|
|
import Utility.Exception
|
|
|
|
import Control.Applicative
|
|
|
|
import Data.Maybe
|
|
|
|
import Prelude
|
|
|
|
import qualified System.Environment as E
|
|
|
|
|
|
|
|
getEnv :: String -> IO (Maybe String)
|
|
|
|
getEnv = catchMaybeIO . E.getEnv
|
|
|
|
|
|
|
|
getEnvDefault :: String -> String -> IO String
|
|
|
|
getEnvDefault var fallback = fromMaybe fallback <$> getEnv var
|