Seth Woolley's Man Viewer

setenv(3) - setenv, setenv - change or add an environment variable - man 3 setenv

([section] manual, -k keyword, -K [section] search, -f whatis)
man plain no title

SETENV(3)                  Linux Programmer's Manual                 SETENV(3)



NAME
       setenv - change or add an environment variable

SYNOPSIS
       #include <stdlib.h>

       int setenv(const char *name, const char *value, int overwrite);

       int unsetenv(const char *name);

DESCRIPTION
       The  setenv()  function  adds the variable name to the environment with
       the value value, if(3,n) name does not already exist.  If name does exist in(1,8)
       the  environment,  then  its  value is changed to value if(3,n) overwrite is
       non-zero; if(3,n) overwrite is zero, then the value of name is not  changed.

       The unsetenv() function deletes the variable name from the environment.

RETURN VALUE
       The setenv() function returns zero on  success,  or  -1  if(3,n)  there  was
       insufficient space in(1,8) the environment.  The unsetenv() function returns
       zero on success, or -1 on error(8,n), with errno set(7,n,1 builtins) to indicate  the  cause
       of the error.

ERRORS
       EINVAL name contained an '=' character.

CONFORMING TO
       BSD 4.3

NOTES
       Prior to glibc 2.2.2, unsetenv() was prototyped as returning void; more
       recent glibc versions follow the SUSv3-compliant prototype shown in(1,8) the
       SYNOPSIS.

BUGS
       SUSv3  specifies  that if(3,n) name contains an '=' character, then setenv()
       should fail with the error(8,n) EINVAL; however,  glibc  currently  (v2.3.3)
       allows an '=' sign in(1,8) name.  Portable applications should avoid this!

SEE ALSO
       clearenv(3), getenv(3), putenv(3), environ(5)



BSD                               2004-05-09                         SETENV(3)

References for this manual (incoming links)