From e21f19001551eddbb8d27acea1327590ce124461 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 18 Apr 2015 10:47:14 -0700 Subject: Adding getenv, setenv and unsetenv. * lib.c (setenv, unsetenv): Changed static functions to external. Moved them out of the #if !HAVE_TIMEGM block. * lib.h (setenv, unsetenv): Declared. * sysif.c (getenv_wrap, setenv_wrap, unsetenv_wrap): New functions. (sysif_init): Registered getenv, setenv and unsetenv. * txr.1: Documented getenv, setenv and unsetenv. * tl.vim, txr.vim: Regenerated. --- txr.1 | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'txr.1') diff --git a/txr.1 b/txr.1 index 8c4ccc07..d7c665e9 100644 --- a/txr.1 +++ b/txr.1 @@ -24106,6 +24106,11 @@ on the output (since the UTC zone by definition doesn't have daylight savings time). .SS* Environment Variables and Command Line + +Note that environment variable names, their values, and command line +arguments are all regarded as being externally encoded in UTF-8. \*(TX performs +the encoding and decoding automatically. + .coNP Special variables @ *args* and @ *args-full* .desc The @@ -24160,6 +24165,67 @@ function constructs and returns an hash. The hash is populated with the environment variables, represented as key-value pairs. +.coNP Functions @, getenv @, setenv and @ unsetenv +.synb +.mets (getenv << name ) +.mets (setenv < name < value <> [ overwrite-p ]) +.mets (unsetenv << name ) +.syne +.desc +These functions provide access to, as well as manipulation of, environment +variables. Of these three, +.code setenv +and +.code unsetenv +might not be available on some platforms, or +.code unsetenv +might be be present in a simulated form which sets the variable +.meta name +to the empty string rather than deleting it. + +The +.code getenv +function searches the environment for the environment variable whose name +is +.metn name . +If the variable is found, its value is returned. Otherwise +.code nil +is returned. + +The +.code setenv +function creates or modifies the environment variable indicated by +.metn name . +The +.meta value +string argument specifies the new value for the variable. + +If the +.meta overwrite-p +argument is specified, and is true, +then the variable is overwritten if it already exists. +If the argument is false, then the variable is not modified if it +already exists. If the argument is not specified, it defaults +to the value +.metn t, +effectively giving rise to a two-argument form of +.code setenv +which creates or overwrites environment variables. + +The +.code setenv +function unconditionally returns +.meta value +regardless of whether or not it overwrites an existing variable. + +The +.code unsetenv +function removes the enviornment variable +specified by +.metn name , +if it exists. On some platforms, it instead sets the environment variable +to the empty string. + .SS* System Programming .coNP Function @ errno .synb -- cgit v1.2.3