/usr/bin/dash: Difference between revisions

Line 210: Line 210:


=== Pipelines ===
=== Pipelines ===
    A pipeline is a sequence of one or more commands separated by the control operator |.  The standard
パイプラインは、制御演算子|で区切られた1つ以上のコマンドのシーケンスである。 最後のコマンド以外のすべての標準出力は、次のコマンドの標準入力に接続される。 最後のコマンドの標準出力は、通常通り、シェルから継承される。
    output of all but the last command is connected to the standard input of the next command.  The stan‐
    dard output of the last command is inherited from the shell, as usual.


    The format for a pipeline is:
パイプラインの形式は次の通りである:


          [!] command1 [| command2 ...]
[!] command1 [| command2 ...]


    The standard output of command1 is connected to the standard input of command2.  The standard input,
コマンド1の標準出力は、コマンド2の標準入力に接続される。 コマンドの標準入力、標準出力、またはその両方は、コマンドの一部であるリダイレクト演算子によって指定されたリダイレクトの前に、パイプラインによって割り当てられたと見なされる。
    standard output, or both of a command is considered to be assigned by the pipeline before any redi‐
    rection specified by redirection operators that are part of the command.


    If the pipeline is not in the background (discussed later), the shell waits for all commands to com‐
パイプラインがバックグラウンドにない場合(後述)、シェルはすべてのコマンドの完了を待つ。
    plete.


    If the reserved word ! does not precede the pipeline, the exit status is the exit status of the last
予約語! がパイプラインの前にない場合、終了ステータスはパイプラインで指定された最後のコマンドの終了ステータスになる。 そうでない場合、終了ステータスは、最後のコマンドの終了ステータスの論理NOTとなる。 すなわち、最後のコマンドが0を返す場合、終了ステータスは1であり、最後のコマンドが0より大きい値を返す場合、終了ステータスは0である。
    command specified in the pipeline.  Otherwise, the exit status is the logical NOT of the exit status
    of the last command.  That is, if the last command returns zero, the exit status is 1; if the last
    command returns greater than zero, the exit status is zero.


    Because pipeline assignment of standard input or standard output or both takes place before redirect‐
標準入力または標準出力、あるいはその両方のパイプラインの割り当ては、リダイレクトの前に行われるため、リダイレクトによって変更されることがある。 例えば、次のようになる:
    ion, it can be modified by redirection.  For example:


          $ command1 2>&1 | command2
$ command1 2>&1 | command2


    sends both the standard output and standard error of command1 to the standard input of command2.
は、コマンド1の標準出力と標準エラーの両方を、コマンド2の標準入力に送信する。


    A ; or ⟨newline⟩ terminator causes the preceding AND-OR-list (described next) to be executed sequen‐
または⟨ニューライン⟩の終端は、先行するAND-ORリスト(次に説明)を順次実行させる;&は先行するAND-ORリストを非同期に実行する。
    tially; a & causes asynchronous execution of the preceding AND-OR-list.


    Note that unlike some other shells, each process in the pipeline is a child of the invoking shell (un‐
他のシェルとは異なり、パイプラインの各プロセスは起動したシェルの子であることに注意すること(シェルの組み込みでない場合は、現在のシェルで実行されるが、環境に与える影響はすべて消去される)。
    less it is a shell builtin, in which case it executes in the current shell – but any effect it has on
    the environment is wiped).


=== Background Commands – & ===
=== Background Commands – & ===