Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Synopsis
- getArgs :: IO [String]
- getFullArgs :: IO [String]
- withArgs :: [String] -> IO a -> IO a
- getProgName :: IO String
- withProgName :: String -> IO a -> IO a
- getExecutablePath :: IO FilePath
- getEnvironment :: IO [(String, String)]
- getEnv :: String -> IO (Maybe String)
- getEnvDefault :: String -> String -> IO String
- setEnv :: String -> String -> Bool -> IO ()
- unsetEnv :: String -> IO ()
Documentation
Computation getArgs
returns a list of the program's command
line arguments (not including the program name).
getFullArgs :: IO [String] #
Computation getFullArgs
is the "raw" version of getArgs
, similar
to argv
in other languages. It returns a list of the program's
command line arguments, starting with the program name, and
including those normally eaten by the RTS (+RTS ... -RTS).
getProgName :: IO String #
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.
withProgName :: String -> IO a -> IO a #
withProgName
name act
- while executing action act
,
have getProgName
return name
.
getExecutablePath :: IO FilePath #
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.)
Since base 4.11.0.0, getExecutablePath
resolves symlinks on Windows.
If an executable is launched through a symlink, getExecutablePath
returns the absolute path of the original executable.
Since: base-4.6.0.0
getEnvironment :: IO [(String, String)] #
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.
Get an environment value or a default value.