unix-2.7.2.2: POSIX functionality

Copyright | (c) The University of Glasgow 2002
License | BSD-style (see the file libraries/base/LICENSE)
Maintainer | libraries@haskell.org
Stability | provisional
Portability | non-portable (requires POSIX)
Safe Haskell | Safe
Language | Haskell2010

System.Posix.Env

Description

POSIX environment support

Synopsis

- getEnv :: String -> IO (Maybe String)
- getEnvDefault :: String -> String -> IO String
- getEnvironmentPrim :: IO [String]
- getEnvironment :: IO [(String, String)]
- setEnvironment :: [(String, String)] -> IO ()
- putEnv :: String -> IO ()
- setEnv :: String -> String -> Bool -> IO ()
- unsetEnv :: String -> IO ()
- clearEnv :: IO ()

# Documentation

getEnv #

Arguments

:: String | variable name
-> IO (Maybe String) | variable value

`getEnv` looks up a variable in the environment.

getEnvDefault #

Arguments

:: String | variable name
-> String | fallback value
-> IO String | variable value or fallback value

`getEnvDefault` is a wrapper around `getEnv` where the programmer can specify a fallback if the variable is not found in the environment.

getEnvironmentPrim :: IO [String] #

getEnvironment #

Arguments

:: IO [(String, String)]

    [(key,value)]

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

setEnvironment #

Arguments

:: [(String, String)]

    [(key,value)]

-> IO () |

`setEnvironment` resets the entire environment to the given list of `(key,value)` pairs.

putEnv #

Arguments

:: String | "key=value"
-> IO () |

`putEnv` function takes an argument of the form `name=value` and is equivalent to `setEnv(key,value,True{-overwrite-})`.

setEnv #

Arguments

:: String | variable name
-> String | variable value
-> Bool | overwrite
-> IO () |

The `setEnv` function inserts or resets the environment variable name in the current environment list. If the variable `name` does not exist in the list, it is inserted with the given value. If the variable does exist, the argument `overwrite` is tested; if `overwrite` is `False`, the variable is not reset, otherwise it is reset to the given value.

unsetEnv #

Arguments

:: String | variable name
-> IO () |

The `unsetEnv` function deletes all instances of the variable name from the environment.

clearEnv :: IO () #

The `clearEnv` function clears the environment of all name-value pairs.