/usr/bin/bash: Difference between revisions

Line 1,199: Line 1,199:


== ENVIRONMENT ==
== ENVIRONMENT ==
      When a program is invoked it is given an array of strings called the environment.  This is a list
プログラムが起動されると、環境と呼ばれる文字列の配列が与えられる。 これはname=valueという形式の名前と値のペアのリストである。
      of name-value pairs, of the form name=value.


      The shell provides several ways to manipulate the environment.  On invocation,  the  shell  scans
シェルは環境を操作するいくつかの方法を提供する。 起動時にシェルは自身の環境をスキャンし、見つかった名前ごとにパラメータを作成し、子プロセスにエクスポートするように自動的にマークする。 実行されたコマンドは環境を継承する。 exportコマンドとdeclare -xコマンドにより、パラメータや関数を環境に追加したり、環境から削除したりすることができる。 環境内のパラメータの値が変更されると、新しい値が環境の一部となり、古い値を置き換える。 実行されたコマンドによって継承される環境は、シェルの初期環境からなり、その値はシェルで変更することができ、unsetコマンドで削除されたペアと、exportコマンドとdeclare -xコマンドで追加されたペアが含まれる。
      its own environment and creates a parameter for each name found, automatically marking it for ex‐
      port to child processes.  Executed commands inherit the environment.  The export and  declare  -x
      commands  allow parameters and functions to be added to and deleted from the environment.  If the
      value of a parameter in the environment is modified, the new value becomes part of  the  environ‐
      ment,  replacing  the  old.  The  environment inherited by any executed command consists of the
      shell's initial environment, whose values may be modified in the shell, less any pairs removed by
      the unset command, plus any additions via the export and declare -x commands.


      The  environment  for any simple command or function may be augmented temporarily by prefixing it
単純なコマンドや関数の環境は、上記の[[#PARAMETERS|PARAMETERS ]]で説明されているように、パラメータ割り当てを前に置くことで一時的に拡張することができる。 これらの代入文は、そのコマンドが見る環境だけに影響する。
      with parameter assignments, as described above in PARAMETERS.  These assignment statements affect
      only the environment seen by that command.


      If  the  -k option is set (see the set builtin command below), then all parameter assignments are
kオプションが設定されている場合(後述のset builtinコマンドを参照)、コマンド名の前にあるものだけでなく、すべてのパラメータ割り当てがコマンドの環境に置かれる。
      placed in the environment for a command, not just those that precede the command name.


      When bash invokes an external command, the variable _ is set to the full filename of the  command
bashが外部コマンドを呼び出すと、変数_にコマンドの完全なファイル名が設定され、そのコマンドの環境に渡される。
      and passed to that command in its environment.


== EXIT STATUS ==
== EXIT STATUS ==