Movatterモバイル変換


[0]ホーム

URL:


base-4.12.0.0: Basic libraries

Copyright(c) Habib Alamin 2017
LicenseBSD-style (see the file libraries/base/LICENSE)
Maintainerlibraries@haskell.org
Stabilityprovisional
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

System.Environment.Blank

Description

A setEnv implementation that allows blank environment variables. Mimics theEnv module from theunix package, but with support for Windows too.

The matrix of platforms that:

  • supportputenv(FOO) to unset environment variables,
  • supportputenv("FOO=") to unset environment variables or set them to blank values,
  • supportunsetenv to unset environment variables,
  • supportsetenv to set environment variables,
  • etc.

is very complicated. Some platforms don't support unsetting of environment variables at all.

Synopsis

Documentation

getExecutablePath ::IOFilePathSource#

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: 4.6.0.0

getArgs ::IO [String]Source#

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

getProgName ::IOStringSource#

ComputationgetProgName returns the name of the program as it wasinvoked.

However, this is hard-to-impossible to implement on some non-UnixOSes, so instead, for maximum portability, we just return the leafnameof the program as invoked. Even then there are some differencesbetween platforms: on Windows, for example, a program invoked as foois probably reallyFOO.EXE, and that is whatgetProgName will return.

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

withArgsargs act - while executing actionact, havegetArgsreturnargs.

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

withProgNamename act - while executing actionact,havegetProgName returnname.

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, thekey is the whole entry and thevalue is the empty string.

getEnv ::String ->IO (MaybeString)Source#

Similar tolookupEnv.

getEnvDefaultSource#

Arguments

::String

variable name

->String

fallback value

->IOString

variable value or fallback value

Get an environment value or a default value.

setEnvSource#

Arguments

::String

variable name

->String

variable value

->Bool

overwrite

->IO () 

LikesetEnv, but allows blank environment values and mimics the function signature ofsetEnv from theunix package.

unsetEnv ::String ->IO ()Source#

LikeunsetEnv, but allows for the removal of blank environment variables. May throw an exception if the underlying platform doesn't support unsetting of environment variables.

Produced byHaddock version 2.20.0


[8]ページ先頭

©2009-2025 Movatter.jp