Something went wrong. Try again.
Cider Isn't Darwin Emulation, Really
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239.\" Copyright (c) 1988, 1991, 1993.\" The Regents of the University of California. All rights reserved..\".\" This code is derived from software contributed to Berkeley by.\" the American National Standards Committee X3, on Information.\" Processing Systems..\".\" Redistribution and use in source and binary forms, with or without.\" modification, are permitted provided that the following conditions.\" are met:.\" 1. Redistributions of source code must retain the above copyright.\" notice, this list of conditions and the following disclaimer..\" 2. Redistributions in binary form must reproduce the above copyright.\" notice, this list of conditions and the following disclaimer in the.\" documentation and/or other materials provided with the distribution..\" 3. All advertising materials mentioning features or use of this software.\" must display the following acknowledgement:.\" This product includes software developed by the University of.\" California, Berkeley and its contributors..\" 4. Neither the name of the University nor the names of its contributors.\" may be used to endorse or promote products derived from this software.\" without specific prior written permission..\".\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION).\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT.\" 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.\" SUCH DAMAGE..\".\" @(#)getenv.3 8.2 (Berkeley) 12/11/93.\" $FreeBSD: src/lib/libc/stdlib/getenv.3,v 1.16 2004/07/07 19:57:13 ru Exp $.\".Dd December 11, 1993.Dt GETENV 3.Os.Sh NAME.Nm getenv ,.Nm putenv ,.Nm setenv ,.Nm unsetenv.Nd environment variable functions.Sh LIBRARY.Lb libc.Sh SYNOPSIS.In stdlib.h.Ft char *.Fo getenv.Fa "const char *name".Fc.Ft int.Fo putenv.Fa "char *string".Fc.Ft int.Fo setenv.Fa "const char *name".Fa "const char *value".Fa "int overwrite".Fc.Ft int.Fo unsetenv.Fa "const char *name".Fc.Sh DESCRIPTIONThese functions set, unset and fetch environment variables from thehost.Em environment list .For compatibility with differing environment conventions,the given arguments.Fa nameand.Fa valuemay be appended and prepended,respectively,with an equal sign.Dq Li \&= ..PpThe.Fn getenvfunction obtains the current value of the environment variable,.Fa name ..PpThe.Fn setenvfunction inserts or resets the environment variable.Fa namein the current environment list.If the variable.Fa namedoes not exist in the list,it is inserted with the given.Fa value .If the variable does exist, the argument.Fa overwriteis tested; if.Fa overwriteiszero, thevariable is not reset, otherwise it is resetto the given.Fa value ..PpThe.Fn putenvfunction takes an argument of the form ``name=value'' and isequivalent to:.Bd -literal -offset indentsetenv(name, value, 1);.Ed.PpThe string pointed to by.Fa stringbecomes part of the environment.A program should not alter or free the string,and should not use stack or other transient string variablesas arguments to.Fn putenv .The.Fn setenvfunction is strongly preferred to.Fn putenv ..PpThe.Fn unsetenvfunctiondeletes all instances of the variable name pointed to by.Fa namefrom the list.Note that only the variable name (e.g., "NAME") should be given;"NAME=value" will not work..Sh RETURN VALUESThe.Fn getenvfunction returns the value of the environment variable as a.Dv NUL Ns-terminated string.If the variable.Fa nameis not in the current environment,.Dv NULLis returned..Pp.Rv -std setenv putenv unsetenv.Sh ERRORS.Bl -tag -width Er.It Bq Er EINVALThe function.Fn unsetenvfailed because.Fa namewas not found in the environment list..It Bq Er ENOMEMThe function.Fn setenvor.Fn putenvfailed because it was unable to allocate memory for the environment..El.Sh LEGACY SYNOPSIS.Fd #include <stdlib.h>.Pp.Ft void.br.Fo unsetenv.Fa "const char *name".Fc ;.Pp.Fn unsetenvdoesn't return a value..Sh COMPATIBILITY.Fn putenvno longer copies its input buffer.This often appears in crash logs as a crash in.Fn getenv .Avoid passing local buffers or freeing the memorythat is passed to.Fn putenv .Use.Fn setenv , which still makes an internal copy of its buffers..Pp.Fn unsetenvno longer parses the variable name;e.g., unsetenv ("FOO=BAR") no longer works.Use unsetenv("FOO")..Fn unsetenvalso now returns a status value and will set.Va errnoto EINVAL if.Fa nameis not a defined environment variable..Sh SEE ALSO.Xr csh 1 ,.Xr sh 1 ,.Xr execve 2 ,.Xr compat 5 ,.Xr environ 7.Sh STANDARDSThe.Fn getenvfunction conforms to.St -isoC ..Sh BUGSSuccessive calls to.Fn setenvor.Fn putenvassigning a differently sized.Fa valueto the same.Fa namewill result in a memory leak.The.Fxsemantics for these functions(namely, that the contents of.Fa valueare copied and that old values remain accessible indefinitely) make thisbug unavoidable.Future versions may eliminate one or both of thesesemantic guarantees in order to fix the bug..Sh HISTORYThe functions.Fn setenvand.Fn unsetenvappeared in.At v7 .The.Fn putenvfunction appeared in.Bx 4.3 Reno .