xref: /freebsd/usr.bin/env/env.1 (revision 74bf4e164ba5851606a27d4feff27717452583e5)
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 another
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 variables specified.
70The environment inherited
71by
72.Nm
73is ignored completely.
74.El
75.Pp
76If no
77.Ar utility
78is specified,
79.Nm
80prints out the names and values
81of the variables in the environment, with one name/value pair per line.
82.Pp
83The
84.Nm
85utility is sometimes useful with the
86.Ql #!
87construct (see
88.Xr execve 2 ) .
89The only difference between
90.Dq Li #!/usr/local/bin/foo
91and
92.Dq Li "#!/usr/bin/env /usr/local/bin/foo"
93is that the latter works even if
94.Pa /usr/local/bin/foo
95is itself interpreted.
96Using
97.Nm
98this way also allows one to reference
99.Pa foo
100without the path,
101as well as set up the environment as desired.
102.Sh ENVIRONMENT
103The
104.Nm
105utility uses the
106.Ev PATH
107environment variable to locate the requested
108.Ar utility
109if the name contains no
110.Ql /
111characters.
112.Sh DIAGNOSTICS
113.Ex -std
114An exit status of 126 indicates that
115.Ar utility
116was found, but could not be executed.
117An exit status of 127 indicates that
118.Ar utility
119could not be found.
120.Sh COMPATIBILITY
121The
122.Nm
123utility accepts the
124.Fl
125option as a synonym for
126.Fl i .
127.Sh SEE ALSO
128.Xr printenv 1 ,
129.Xr sh 1 ,
130.Xr execvp 3 ,
131.Xr environ 7
132.Sh STANDARDS
133The
134.Nm
135utility conforms to
136.St -p1003.1-2001 .
137.\".Sh HISTORY
138.\"The
139.\".Nm
140.\"command appeared in
141.\".Bx 3.0 .
142.Sh BUGS
143The
144.Nm
145utility does not handle utility arguments with equal signs
146.Pq Ql =
147in their names, for obvious reasons.
148