Changeset View
Changeset View
Standalone View
Standalone View
lib/libc/stdlib/getenv.3
Show All 26 Lines | |||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
.\" SUCH DAMAGE. | .\" SUCH DAMAGE. | ||||
.\" | .\" | ||||
.\" @(#)getenv.3 8.2 (Berkeley) 12/11/93 | .\" @(#)getenv.3 8.2 (Berkeley) 12/11/93 | ||||
.\" $FreeBSD$ | .\" $FreeBSD$ | ||||
.\" | .\" | ||||
.Dd June 20, 2007 | .Dd January 17, 2021 | ||||
.Dt GETENV 3 | .Dt GETENV 3 | ||||
.Os | .Os | ||||
.Sh NAME | .Sh NAME | ||||
.Nm clearenv , | |||||
0mp: Shouldn't the Makefile be edited as well to install a symlink for clearenv.3? | |||||
.Nm getenv , | .Nm getenv , | ||||
.Nm putenv , | .Nm putenv , | ||||
.Nm setenv , | .Nm setenv , | ||||
.Nm unsetenv | .Nm unsetenv | ||||
.Nd environment variable functions | .Nd environment variable functions | ||||
.Sh LIBRARY | .Sh LIBRARY | ||||
.Lb libc | .Lb libc | ||||
.Sh SYNOPSIS | .Sh SYNOPSIS | ||||
.In stdlib.h | .In stdlib.h | ||||
.Ft int | |||||
.Fn clearenv "void" | |||||
.Ft char * | .Ft char * | ||||
.Fn getenv "const char *name" | .Fn getenv "const char *name" | ||||
.Ft int | .Ft int | ||||
.Fn setenv "const char *name" "const char *value" "int overwrite" | .Fn setenv "const char *name" "const char *value" "int overwrite" | ||||
.Ft int | .Ft int | ||||
.Fn putenv "char *string" | .Fn putenv "char *string" | ||||
.Ft int | .Ft int | ||||
.Fn unsetenv "const char *name" | .Fn unsetenv "const char *name" | ||||
.Sh DESCRIPTION | .Sh DESCRIPTION | ||||
These functions set, unset and fetch environment variables from the | These functions set, unset and fetch environment variables from the | ||||
host | host | ||||
.Em environment list . | .Em environment list . | ||||
.Pp | .Pp | ||||
The | The | ||||
.Fn clearenv | |||||
function clears all environment variables. | |||||
New variables can be added using | |||||
.Fn setenv | |||||
and | |||||
.Fn putenv . | |||||
Done Inline ActionsI believe you meant putenv instead of getenv. scf: I believe you meant `putenv` instead of `getenv`. | |||||
.Pp | |||||
The | |||||
.Fn getenv | .Fn getenv | ||||
function obtains the current value of the environment variable, | function obtains the current value of the environment variable, | ||||
.Fa name . | .Fa name . | ||||
The application should not modify the string pointed | The application should not modify the string pointed | ||||
to by the | to by the | ||||
.Fn getenv | .Fn getenv | ||||
function. | function. | ||||
.Pp | .Pp | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | |||||
.Dv NUL Ns | .Dv NUL Ns | ||||
-terminated string. | -terminated string. | ||||
If the variable | If the variable | ||||
.Fa name | .Fa name | ||||
is not in the current environment, | is not in the current environment, | ||||
.Dv NULL | .Dv NULL | ||||
is returned. | is returned. | ||||
.Pp | .Pp | ||||
.Rv -std setenv putenv unsetenv | .Rv -std clearenv setenv putenv unsetenv | ||||
.Sh ERRORS | .Sh ERRORS | ||||
.Bl -tag -width Er | .Bl -tag -width Er | ||||
.It Bq Er EINVAL | .It Bq Er EINVAL | ||||
The function | The function | ||||
.Fn getenv , | .Fn getenv , | ||||
.Fn setenv | .Fn setenv | ||||
or | or | ||||
.Fn unsetenv | .Fn unsetenv | ||||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | |||||
.Fa string | .Fa string | ||||
and insert it into the environment using | and insert it into the environment using | ||||
.Fn setenv . | .Fn setenv . | ||||
This was changed to use | This was changed to use | ||||
.Fa string | .Fa string | ||||
as the memory location of the ``name=value'' pair to follow the | as the memory location of the ``name=value'' pair to follow the | ||||
.Tn POSIX | .Tn POSIX | ||||
specification. | specification. | ||||
.Pp | |||||
The | |||||
.Fn clearenv | |||||
was added in | |||||
Done Inline ActionsI doubt it ('first appeared in glibc'). Linux man page states CONFORMING TO Various UNIX variants (DG/UX, HP-UX, QNX, ...). POSIX.9 (bindings for FORTRAN77). kib: I doubt it ('first appeared in glibc'). Linux man page states
```
CONFORMING TO
Various… | |||||
.Fx 14 . | |||||
.Sh BUGS | .Sh BUGS | ||||
Successive calls to | Successive calls to | ||||
.Fn setenv | .Fn setenv | ||||
that assign a larger-sized | that assign a larger-sized | ||||
.Fa value | .Fa value | ||||
than any previous value to the same | than any previous value to the same | ||||
.Fa name | .Fa name | ||||
will result in a memory leak. | will result in a memory leak. | ||||
Show All 9 Lines |
Shouldn't the Makefile be edited as well to install a symlink for clearenv.3?