System.Posix.Env.ByteString

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 | Trustworthy
Language | Haskell2010

System.Posix.Env.ByteString

Contents

- Environment Variables
- Program arguments

Description

POSIX environment support

Synopsis

- getEnv :: ByteString -> IO (Maybe ByteString)
- getEnvDefault :: ByteString -> ByteString -> IO ByteString
- getEnvironmentPrim :: IO [ByteString]
- getEnvironment :: IO [(ByteString, ByteString)]
- putEnv :: ByteString -> IO ()
- setEnv :: ByteString -> ByteString -> Bool -> IO ()
- unsetEnv :: ByteString -> IO ()
- getArgs :: IO [ByteString]

# Environment Variables

getEnv #

Arguments

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

`getEnv` looks up a variable in the environment.

getEnvDefault #

Arguments

:: ByteString | variable name
-> ByteString | fallback value
-> IO ByteString | 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 [ByteString] #

getEnvironment #

Arguments

:: IO [(ByteString, ByteString)] |
    [(key,value)]

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

putEnv #

Arguments

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

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

setEnv #

Arguments

:: ByteString | variable name
-> ByteString | 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

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

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

# Program arguments

getArgs :: IO [ByteString] #

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

Unlike `getArgs`, this function does no Unicode decoding of the arguments; you get the exact bytes that were passed to the program by the OS. To interpret the arguments as text, some Unicode decoding should be applied.