| Qore Programming Language Reference Manual 2.2.0

Loading...
Searching...
No Matches
Functions
Environment Functions

## Functions
*string | Qore::getenv (string var)
| Retrieves the value of an environment variable or NOTHING if the variable is not set.
nothing | Qore::getenv ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
int | Qore::setenv (string env, softstring val)
| Sets an environment variable to a value.
nothing | Qore::setenv ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
int | Qore::unsetenv (string env)
| Unsets an environment variable.
nothing | Qore::unsetenv ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

## Detailed Description

Environment functions

## Function Documentation

## ◆ getenv() [1/2]

nothing Qore::getenv | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Restrictions:
  Qore::PO_NO_EXTERNAL_INFO

Code Flags:
  NOOP

## ◆ getenv() [2/2]

*string Qore::getenv | ( | string | var | ) |

Retrieves the value of an environment variable or NOTHING if the variable is not set.

Restrictions:
  Qore::PO_NO_EXTERNAL_INFO

Code Flags:
  CONSTANT

Parameters

  var | the name of the environment variable

Returns
  the value of an environment variable or NOTHING if the variable is not set

Example:
  *string v = getenv("PATH");

Since
  Qore 0.8.4 tagged with PO_NO_EXTERNAL_INFO

## ◆ setenv() [1/2]

nothing Qore::setenv | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Restrictions:
  Qore::PO_NO_PROCESS_CONTROL

Code Flags:
  NOOP

## ◆ setenv() [2/2]

int Qore::setenv | ( | string | env,
|  | softstring | val )

Sets an environment variable to a value.

Restrictions:
  Qore::PO_NO_PROCESS_CONTROL

Parameters

  env | the name of the environment variable
  val | the new value of the environment variable

Returns
  -1 for error or 0 for success; if an error occurs, errno() and/or strerror() can be used to get the error code or message

Example:
  if (setenv("PATH", "/bin:/usr/bin"))
  printf("error setting PATH: %s\n", strerror());

See also
  unsetenv() to unset or clear an environment variable

Since
  Qore 0.8.4 tagged with PO_NO_PROCESS

## ◆ unsetenv() [1/2]

nothing Qore::unsetenv | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Restrictions:
  Qore::PO_NO_EXTERNAL_INFO

Code Flags:
  NOOP

## ◆ unsetenv() [2/2]

int Qore::unsetenv | ( | string | env | ) |

Unsets an environment variable.

Restrictions:
  Qore::PO_NO_PROCESS_CONTROL

Parameters

  env | the name of the environment variable to unset

Returns
  -1 for error or 0 for success; if an error occurs, errno() and/or strerror() can be used to get the error code or message

Example:
  if (unsetenv("PATH"))
  printf("error unsetting PATH: %s\n", strerror());

See also
  setenv() to set an environment variable to a value

Since
  Qore 0.8.4 tagged with PO_NO_PROCESS