1.\" $OpenBSD: env.1,v 1.21 2024/07/28 10:08:44 kn Exp $ 2.\" Copyright (c) 1980, 1990 The Regents of the University of California. 3.\" All rights reserved. 4.\" 5.\" This code is derived from software contributed to Berkeley by 6.\" the Institute of Electrical and Electronics Engineers, Inc. 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. Neither the name of the University nor the names of its contributors 16.\" may be used to endorse or promote products derived from this software 17.\" without specific prior written permission. 18.\" 19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" SUCH DAMAGE. 30.\" 31.\" from: @(#)printenv.1 6.7 (Berkeley) 7/28/91 32.\" 33.Dd $Mdocdate: July 28 2024 $ 34.Dt ENV 1 35.Os 36.Sh NAME 37.Nm env 38.Nd set and print environment 39.Sh SYNOPSIS 40.Nm env 41.Op Fl i 42.Op Fl u Ar name 43.Oo 44.Ar name Ns = Ns Ar value ... 45.Oc 46.Oo 47.Ar utility 48.Op Ar argument ... 49.Oc 50.Sh DESCRIPTION 51.Nm 52executes 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 Ds 66.It Fl i 67Causes 68.Nm 69to completely ignore the environment it inherits. 70.It Fl u Ar name 71Remove 72.Ar name 73from the environment. 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 82.Ar name Ns = Ns Ar value 83pair per line. 84.Pp 85.Nm 86doesn't handle commands with equal 87.Pq Sq = 88signs in their 89names, for obvious reasons. 90.Sh EXIT STATUS 91The 92.Nm 93utility exits with one of the following values: 94.Bl -tag -width Ds 95.It 0 96.Nm 97completed successfully and, if 98.Ar utility 99was specified, it was invoked and completed successfully too. 100.It 1 101An invalid command line option was passed to 102.Nm 103and 104.Ar utility 105was not invoked, or 106.Ar utility 107was invoked but failed with exit status 1. 108.It 2\(en125, 128\(en255 109.Ar utility 110was invoked but failed with this exit status; 111see its manual page for more information. 112.It 126 113.Ar utility 114was found but could not be invoked, or it was invoked but failed 115with exit status 126. 116.It 127 117.Ar utility 118could not be found, or it was invoked but failed with exit status 127. 119.El 120.Sh SEE ALSO 121.Xr execvp 3 , 122.Xr environ 7 123.Sh STANDARDS 124The 125.Nm 126utility is compliant with the 127.St -p1003.1-2008 128specification. 129The flag 130.Op Fl u 131is an extension to that specification. 132.Pp 133The historic 134.Fl 135option has been deprecated but is still supported in this implementation. 136