xref: /freebsd/usr.bin/env/env.1 (revision 7660b554bc59a07be0431c17e0e33815818baa69)
1.\" Copyright (c) 1980, 1990, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the Institute of Electrical and Electronics Engineers, Inc.
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\"    must display the following acknowledgement:
16.\"	This product includes software developed by the University of
17.\"	California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\"    may be used to endorse or promote products derived from this software
20.\"    without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\" From @(#)printenv.1	8.1 (Berkeley) 6/6/93
35.\" From FreeBSD: src/usr.bin/printenv/printenv.1,v 1.17 2002/11/26 17:33:35 ru Exp
36.\" $FreeBSD$
37.\"
38.Dd May 12, 2003
39.Dt ENV 1
40.Os
41.Sh NAME
42.Nm env
43.Nd set and print environment
44.Sh SYNOPSIS
45.Nm
46.Op Fl i
47.Op Ar name Ns = Ns Ar value ...
48.Op Ar utility Op Ar argument ...
49.Sh DESCRIPTION
50The
51.Nm
52utility executes
53.Ar utility
54after modifying the environment as
55specified on the command line.
56The option
57.Ar name Ns = Ns Ar value
58specifies
59an environment variable,
60.Ar name  ,
61with a value of
62.Ar value  .
63.Pp
64The options are as follows:
65.Bl -tag -width indent
66.It Fl i
67Execute the
68.Ar utility
69with only those environment values specified.
70The environment inherited
71by
72.Nm env
73is ignored completely.
74.El
75.Pp
76If no utility is specified,
77.Nm env
78prints out the names and values
79of the variables in the environment, with one name/value pair per line.
80.Pp
81The
82.Nm env
83utility is sometimes useful with the
84.Dq Li #!
85construct (see
86.Xr execve 2 ) .
87The only difference between
88.Dq Li #!/usr/local/bin/foo
89and
90.Dq Li "#!/usr/bin/env\ /usr/local/bin/foo"
91is that the latter works even if
92.Pa /usr/local/bin/foo
93is itself interpreted.
94Using
95.Nm env
96this way also allows one to reference
97.Pa foo
98without the path,
99as well as set up the environment as desired.
100.Sh ENVIRONMENT
101The
102.Nm env
103utility uses the
104.Ev PATH
105environment variable is used to locate the requested
106.Ar utility
107if the name contains no
108.Ql /
109characters.
110.Sh DIAGNOSTICS
111.Ex -std env
112An exit status of 126 indicates
113.Ar utility
114was found, but could not be executed.
115An exit status of 127 indicates
116.Ar utility
117could not be found.
118.Sh COMPATIBILITY
119The
120.Nm env
121utility accepts the
122.Fl
123option as a synonym for
124.Fl i .
125.Sh SEE ALSO
126.Xr printenv 1 ,
127.Xr sh 1 ,
128.Xr execvp 3 ,
129.Xr environ 7
130.Sh STANDARDS
131The
132.Nm env
133utility conforms to
134.St -p1003.1-2001 .
135.\".Sh HISTORY
136.\"The
137.\".Nm
138.\"command appeared in
139.\".Bx 3.0 .
140.Sh BUGS
141The
142.Nm env
143utility doesn't handle utility arguments with equal (``='') signs in their
144names, for obvious reasons.
145