xref: /illumos-gate/usr/src/man/man1/env.1 (revision dd72704bd9e794056c558153663c739e2012d721)

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 SunOS 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.

The contents of this file are subject to the terms of the
Common Development and Distribution License (the "License").
You may not use this file except in compliance with the License.

You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
or http://www.opensolaris.org/os/licensing.
See the License for the specific language governing permissions
and limitations under the License.

When distributing Covered Code, include this CDDL HEADER in each
file and include the License file at usr/src/OPENSOLARIS.LICENSE.
If applicable, add the following below this CDDL HEADER, with the
fields enclosed by brackets "[]" replaced with your own identifying
information: Portions Copyright [yyyy] [name of copyright owner]


Copyright 1989 AT&T
Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
Portions Copyright (c) 2002, Sun Microsystems, Inc. All Rights Reserved.

ENV 1 "Jan 2, 2002"
NAME
env - set environment for command invocation
SYNOPSIS

/usr/bin/env [-i | -] [name=value]... [utility [arg... ]]

/usr/xpg4/bin/env [-i | -] [name=value]...
 [utility [arg... ]]
DESCRIPTION

The env utility obtains the current environment, modifies it according to its arguments, then invokes the utility named by the utility operand with the modified environment.

Optional arguments are passed to utility. If no utility operand is specified, the resulting environment is written to the standard output, with one name=value pair per line.

If env executes commands with arguments, it uses the default shell /usr/bin/sh (see sh(1)).

OPTIONS

The following options are supported: -i | -

Ignores the environment that would otherwise be inherited from the current shell. Restricts the environment for utility to that specified by the arguments.

OPERANDS

The following operands are supported: name=value

Arguments of the form name=value modify the execution environment, and are placed into the inherited environment before utility is invoked.

utility

The name of the utility to be invoked. If utility names any of the special shell built-in utilities, the results are undefined.

arg

A string to pass as an argument for the invoked utility.

EXAMPLES

Example 1 Invoking utilities with new PATH values

The following utility:

example% env -i PATH=/mybin mygrep xyz myfile 

invokes the utility mygrep with a new PATH value as the only entry in its environment. In this case, PATH is used to locate mygrep, which then must reside in /mybin.

ENVIRONMENT VARIABLES

See environ(7) for descriptions of the following environment variables that affect the execution of env: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES, and NLSPATH. PATH

Determine the location of the utility. If PATH is specified as a name=value operand to env, the value given shall be used in the search for utility.

EXIT STATUS

If utility is invoked, the exit status of env is the exit status of utility. Otherwise, the env utility returns one of the following exit values: 0

Successful completion.

1-125

An error occurred.

126

utility was found but could not be invoked.

127

utility could not be found.

ATTRIBUTES

See attributes(7) for descriptions of the following attributes:

"/usr/bin"
ATTRIBUTE TYPE ATTRIBUTE VALUE
CSI enabled
ATTRIBUTE TYPE ATTRIBUTE VALUE
CSI enabled
Interface Stability Standard
SEE ALSO

ksh (1), sh (1), exec (2), profile (5), attributes (7), environ (7), standards (7)