'\" 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 "2011 年 7 月 12 日" "SunOS 5.11" "用户命令" .SH 名称 env \- 设置命令调用环境 .SH 用法概要 .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 描述 .sp .LP \fBenv\fR 实用程序可以获取当前环境,根据其参数进行修改,然后通过修改后的环境调用由 \fIutility\fR 操作数指定的实用程序。 .sp .LP 可选参数将传递给 \fIutility\fR。如果未指定任何 \fIutility\fR 操作数,则生成的环境会写入标准输出,并且每行有一个 \fIname\fR\fB=\fR\fIvalue\fR 对。 .SS "\fB/usr/bin\fR" .sp .LP 如果 \fBenv\fR 执行命令时使用参数,则使用缺省的 shell \fB/usr/bin/sh\fR(请参见 \fBsh\fR(1))。 .SS "\fB/usr/xpg4/bin\fR" .sp .LP 如果 \fBenv\fR 执行命令时使用参数,则使用 \fB/usr/xpg4/bin/sh\fR(请参见 \fBksh88\fR(1))。 .SH 选项 .sp .LP 支持以下选项: .sp .ne 2 .mk .na \fB\fB-i\fR | \fB-\fR \fR .ad .RS 11n .rt 忽略在其他情况下可能会从当前 shell 继承的环境。将 \fIutility\fR 所用的环境限制为参数指定的环境。 .RE .SH 操作数 .sp .LP 支持下列操作数: .sp .ne 2 .mk .na \fB\fIname\fR\fB=\fR\fIvalue\fR \fR .ad .RS 15n .rt 形式为 \fIname\fR\fB=\fR\fIvalue\fR 的参数可修改执行环境,并会在调用 \fIutility\fR 之前置入继承的环境。 .RE .sp .ne 2 .mk .na \fB\fIutility\fR \fR .ad .RS 15n .rt 要调用的实用程序名称。如果 \fIutility\fR 指定了任意 shell 特殊内置实用程序,则结果是不确定的。 .RE .sp .ne 2 .mk .na \fB\fIarg\fR \fR .ad .RS 15n .rt 作为所调用实用程序的参数传递的字符串。 .RE .SH 示例 .LP \fB示例 1 \fR使用新的 PATH 值调用实用程序 .sp .LP 以下实用程序: .sp .in +2 .nf example% \fBenv -i PATH=/mybin mygrep xyz myfile \fR .fi .in -2 .sp .sp .LP 可调用实用程序 \fBmygrep\fR,其中以新的 \fBPATH\fR 值作为其环境中的唯一条目。在这种情况下,\fBPATH\fR 用于定位 \fBmygrep\fR,后者必须位于 \fB/mybin\fR 中。 .SH 环境变量 .sp .LP 有关影响 \fBenv\fR 执行的以下环境变量的说明,请参见 \fBenviron\fR(5):\fBLANG\fR、\fBLC_ALL\fR、\fBLC_CTYPE\fR、\fBLC_MESSAGES\fR 和 \fBNLSPATH\fR。 .sp .ne 2 .mk .na \fB\fBPATH\fR\fR .ad .RS 8n .rt 确定 \fIutility\fR 的位置。如果以 \fIname\fR=\fIvalue\fR 操作数来指定 \fBenv\fR 的 \fBPATH\fR,则应使用给定的值来搜索 \fIutility\fR。 .RE .SH 退出状态 .sp .LP 如果调用了 \fIutility\fR,则 \fBenv\fR 的退出状态即为 \fIutility\fR 的退出状态。否则,\fBenv\fR 实用程序会返回以下退出值之一: .sp .ne 2 .mk .na \fB\fB0\fR\fR .ad .RS 10n .rt 成功完成。 .RE .sp .ne 2 .mk .na \fB\fB1-125\fR \fR .ad .RS 10n .rt 出现错误。 .RE .sp .ne 2 .mk .na \fB\fB126\fR \fR .ad .RS 10n .rt \fIutility\fR 已找到但无法调用。 .RE .sp .ne 2 .mk .na \fB\fB127\fR \fR .ad .RS 10n .rt 无法找到 \fIutility\fR。 .RE .SH 属性 .sp .LP 有关下列属性的说明,请参见 \fBattributes\fR(5): .SS "/usr/bin" .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . 属性类型属性值 _ 可用性system/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) . 属性类型属性值 _ 可用性system/xopen/xcu4 _ CSIenabled(已启用) _ 接口稳定性Committed(已确定) _ 标准请参见 \fBstandards\fR(5)。 .TE .SH 另请参见 .sp .LP \fBksh88\fR(1)、\fBsh\fR(1)、\fBexec\fR(2)、\fBprofile\fR(4)、\fBattributes\fR(5)、\fBenviron\fR(5)、\fBstandards\fR(5)