Qore Programming Language Reference Manual: Environment Functions

Qore Programming Language Reference Manual 0.8.11

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

All Classes Namespaces Functions Variables Groups Pages
Functions
Environment Functions

## Functions
*string | Qore::getenv (string var)
| Retrieves the value of an environment variable or NOTHING if the variable is not set. More...
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. More...
int | Qore::setenv (string env, softstring val)
| Sets an environment variable to a value. More...
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. More...
int | Qore::unsetenv (string env)
| Unsets an environment variable. More...
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. More...

## Detailed Description

Environment functions

## Function Documentation

*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:
  my *string $v = getenv("PATH");

Since
  Qore 0.8.4 tagged with PO_NO_EXTERNAL_INFO

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

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

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

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

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