getenv()

NAME

getenv(), putenv(), setenv() - environment variable functions

SYNOPSIS

#include <stdlib.h>

char * getenv (const char *name) int putenv (const char *string) int setenv (const char *name, const char *value, int overwrite)

DESCRIPTION

These functions set and fetch environment variables from the host environment list.

The getenv(3) function obtains the current value of the environment variable, name. If the variable name is not in the current environment, a null pointer is returned.

The putenv(3) function inserts or resets an environment variable in the current environment list. The form of the argument string is name=value. If the environment variable name does not exist in the list, it is inserted with the given value. If it does exist, its value is replaced.

The setenv(3) 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 zero, the variable is not reset; otherwise, it is reset to the given value.

RETURN VALUES

The putenv(3) and setenv(3) functions return zero if successful; otherwise the global variable errno is set to indicate the error and a -1 is returned.

ERRORS

[ENOMEM]
The putenv(3) and setenv(3) functions were unable to allocate memory for the environment.

SEE ALSO

sh(1)

exec(2)