setenv-0.1.1.3: A cross-platform library for setting environment variables

Safe Haskell | Safe-Inferred
Language | Haskell98

System.SetEnv

Synopsis

- setEnv :: String -> String -> IO ()
- unsetEnv :: String -> IO ()

# Documentation

setEnv :: String -> String -> IO () Source #

`setEnv name value` sets the specified environment variable to `value`.

Early versions of this function operated under the mistaken belief that setting an environment variable to the empty string on Windows removes that environment variable from the environment. For the sake of compatibility, it adopted that behavior on POSIX. In particular

    setEnv name ""

has the same effect as

    unsetEnv name

If you'd like to be able to set environment variables to blank strings, use `setEnv`.

Throws `IOException` if `name` is the empty string or contains an equals sign.

Beware that this function must not be executed concurrently with `getEnv`, `lookupEnv`, `getEnvironment` and such. One thread reading environment variables at the same time with another one modifying them can result in a segfault, see Setenv is not Thread Safe for discussion.

Since: base-4.7.0.0

unsetEnv :: String -> IO () Source #

`unsetEnv name` removes the specified environment variable from the environment of the current process.

Throws `IOException` if `name` is the empty string or contains an equals sign.

Beware that this function must not be executed concurrently with `getEnv`, `lookupEnv`, `getEnvironment` and such. One thread reading environment variables at the same time with another one modifying them can result in a segfault, see Setenv is not Thread Safe for discussion.

Since: base-4.7.0.0