base-4.6.0.1: Basic libraries

Portabilityportable
Stabilityprovisional
Maintainerlibraries@haskell.org
Safe HaskellSafe

System.Environment

Description

Miscellaneous information about the system environment.

Synopsis

Documentation

getArgs :: IO [String]Source

Computation getArgs returns a list of the program's command line arguments (not including the program name).

getProgName :: IO StringSource

Computation getProgName returns the name of the program as it was invoked.

However, this is hard-to-impossible to implement on some non-Unix OSes, so instead, for maximum portability, we just return the leafname of the program as invoked. Even then there are some differences between platforms: on Windows, for example, a program invoked as foo is probably really FOO.EXE, and that is what getProgName will return.

getExecutablePath :: IO FilePathSource

Returns the absolute pathname of the current executable.

Note that for scripts and interactive sessions, this is the path to the interpreter (e.g. ghci.)

getEnv :: String -> IO StringSource

Computation getEnv var returns the value of the environment variable var. For the inverse, POSIX users can use putEnv.

This computation may fail with:

lookupEnv :: String -> IO (Maybe String)Source

Return the value of the environment variable var, or Nothing if there is no such value.

For POSIX users, this is equivalent to getEnv.

withArgs :: [String] -> IO a -> IO aSource

withArgs args act - while executing action act, have getArgs return args.

withProgName :: String -> IO a -> IO aSource

withProgName name act - while executing action act, have getProgName return name.

getEnvironment :: IO [(String, String)]Source

getEnvironment retrieves the entire environment as a list of (key,value) pairs.

If an environment entry does not contain an '=' character, the key is the whole entry and the value is the empty string.