'\" te .\" Copyright (c) 1992, X/Open Company Limited All Rights Reserved .\" Copyright 1989 AT&T .\" Portions Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at http://www.opengroup.org/bookstore/. .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html. This notice shall appear on any product containing this material. .TH env 1 "12 Jul 2011" "SunOS 5.11" "User Commands" .SH NAME env \- set environment for command invocation .SH SYNOPSIS .LP .nf \fB/usr/bin/env\fR [\fB-i\fR | \fB-\fR] [\fIname=value\fR]... [\fIutility\fR [\fIarg\fR... ]] .fi .LP .nf \fB/usr/xpg4/bin/env\fR [\fB-i\fR | \fB-\fR] [\fIname=value\fR]... [\fIutility\fR [\fIarg\fR... ]] .fi .SH DESCRIPTION .sp .LP The \fBenv\fR utility obtains the current environment, modifies it according to its arguments, then invokes the utility named by the \fIutility\fR operand with the modified environment. .sp .LP Optional arguments are passed to \fIutility\fR. If no \fIutility\fR operand is specified, the resulting environment is written to the standard output, with one \fIname\fR\fB=\fR\fIvalue\fR pair per line. .SS "\fB/usr/bin\fR" .sp .LP If \fBenv\fR executes commands with arguments, it uses the default shell \fB/usr/bin/sh\fR (see \fBsh\fR(1)). .SS "\fB/usr/xpg4/bin\fR" .sp .LP If \fBenv\fR executes commands with arguments, it uses \fB/usr/xpg4/bin/sh\fR (see \fBksh88\fR(1)). .SH OPTIONS .sp .LP The following options are supported: .sp .ne 2 .mk .na \fB\fB-i\fR | \fB\(mi\fR \fR .ad .RS 14n .rt Ignores the environment that would otherwise be inherited from the current shell. Restricts the environment for \fIutility\fR to that specified by the arguments. .RE .SH OPERANDS .sp .LP The following operands are supported: .sp .ne 2 .mk .na \fB\fIname\fR\fB=\fR\fIvalue\fR \fR .ad .RS 15n .rt Arguments of the form \fIname\fR\fB=\fR\fIvalue\fR modify the execution environment, and are placed into the inherited environment before \fIutility\fR is invoked. .RE .sp .ne 2 .mk .na \fB\fIutility\fR \fR .ad .RS 15n .rt The name of the utility to be invoked. If \fIutility\fR names any of the special shell built-in utilities, the results are undefined. .RE .sp .ne 2 .mk .na \fB\fIarg\fR \fR .ad .RS 15n .rt A string to pass as an argument for the invoked utility. .RE .SH EXAMPLES .LP \fBExample 1 \fRInvoking utilities with new PATH values .sp .LP The following utility: .sp .in +2 .nf example% \fBenv -i PATH=/mybin mygrep xyz myfile \fR .fi .in -2 .sp .sp .LP invokes the utility \fBmygrep\fR with a new \fBPATH\fR value as the only entry in its environment. In this case, \fBPATH\fR is used to locate \fBmygrep\fR, which then must reside in \fB/mybin\fR. .SH ENVIRONMENT VARIABLES .sp .LP See \fBenviron\fR(5) for descriptions of the following environment variables that affect the execution of \fBenv\fR: \fBLANG\fR, \fBLC_ALL\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR. .sp .ne 2 .mk .na \fB\fBPATH\fR\fR .ad .RS 8n .rt Determine the location of the \fIutility\fR. If \fBPATH\fR is specified as a \fIname\fR=\fIvalue\fR operand to \fBenv\fR, the value given shall be used in the search for \fIutility\fR. .RE .SH EXIT STATUS .sp .LP If \fIutility\fR is invoked, the exit status of \fBenv\fR is the exit status of \fIutility\fR. Otherwise, the \fBenv\fR utility returns one of the following exit values: .sp .ne 2 .mk .na \fB\fB0\fR \fR .ad .RS 10n .rt Successful completion. .RE .sp .ne 2 .mk .na \fB\fB1-125\fR \fR .ad .RS 10n .rt An error occurred. .RE .sp .ne 2 .mk .na \fB\fB126\fR \fR .ad .RS 10n .rt \fIutility\fR was found but could not be invoked. .RE .sp .ne 2 .mk .na \fB\fB127\fR \fR .ad .RS 10n .rt \fIutility\fR could not be found. .RE .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .SS "/usr/bin" .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPEATTRIBUTE VALUE _ Availabilitysystem/core-os _ CSIenabled .TE .SS "/usr/xpg4/bin" .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPEATTRIBUTE VALUE _ Availabilitysystem/xopen/xcu4 _ CSIenabled _ Interface StabilityCommitted _ StandardSee \fBstandards\fR(5). .TE .SH SEE ALSO .sp .LP \fBksh88\fR(1), \fBsh\fR(1), \fBexec\fR(2), \fBprofile\fR(4), \fBattributes\fR(5), \fBenviron\fR(5), \fBstandards\fR(5)