.\" Copyright (c) 1980, 1990, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" the Institute of Electrical and Electronics Engineers, Inc. .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" From @(#)printenv.1 8.1 (Berkeley) 6/6/93 .\" From FreeBSD: src/usr.bin/printenv/printenv.1,v 1.17 2002/11/26 17:33:35 ru Exp .\" %FreeBSD: src/usr.bin/env/env.1,v 1.4 2004/05/19 10:44:24 ru Exp % .\" .\" $FreeBSD$ .\" .Dd May 12, 2003 .Dt ENV 1 .Os .Sh 名称 .Nm env .Nd 環境変数の値を設定、表示する .Sh 書式 .Nm .Op Fl i .Op Ar name Ns = Ns Ar value ... .Op Ar utility Op Ar argument ... .Sh 解説 .Nm ユーティリティは、コマンド行で指定された環境変数の値を変更してから、 別のユーティリティ .Ar utility を実行します。 引数で .Ar name Ns = Ns Ar value を指定することにより、環境変数 .Ar name の値を .Ar value にセットします。 .Pp オプションは次の通りです: .Bl -tag -width indent .It Fl i 指定された環境変数のみを使用して .Ar utility を実行します。 .Nm から継承した環境は無視します。 .El .Pp .Ar utility を指定しないで実行した場合、 .Nm は、環境中の環境変数の名前と値を、 1 行につき名前 / 値の組 1 個の割合で表示します。 .Pp .Nm ユーティリティは、 .Ql #! 構造とともに使用すると役に立つ場合があります ( .Xr execve 2 を参照してください)。 .Dq Li #!/usr/local/bin/foo と .Dq Li "#!/usr/bin/env /usr/local/bin/foo" の唯一の違いは、 .Pa /usr/local/bin/foo 自身が解釈される場合でも後者は動作するという点です。 このように .Nm を使用すると、望み通りに環境を設定できるだけでなく、 .Pa foo をパス無しで参照できます。 .Sh 環境変数 .Nm ユーティリティは、名前に .Ql / が 1 個も含まれない場合、指定された .Ar utility を見付けるために .Ev PATH 環境変数を使用します。 .Sh 診断 .Ex -std 終了ステータス 126 は .Ar utility が見付かったものの実行不可だったことを示します。 終了ステータス 127 は .Ar utility が見付からなかったことを示します。 .Sh 互換性 .Nm ユーティリティは、 .Fl i の同義語として、 .Fl オプションを受け付けます。 .Sh 関連項目 .Xr printenv 1 , .Xr sh 1 , .Xr execvp 3 , .Xr environ 7 .Sh 規格 .Nm ユーティリティは .St -p1003.1-2001 に適合しています。 .Sh バグ 当たり前ですが、 .Nm ユーティリティは、名前にイコール記号 .Pq Ql = を含むユーティリティ引数をちゃんと扱えません。