|   |   | 
| Line 232: | Line 232: | 
|  | 
 |  | 
 | 
|  | === Coprocesses === |  | === Coprocesses === | 
|  |        A coprocess is a shell command preceded by the coproc reserved word.   A coprocess  is  executed
 |  | コプロセスは、coproc予約語を先頭に持つシェルコマンドである。  コプロセスは、コマンドを&制御演算子で終了させたかのように、サブシェル内で非同期に実行され、実行中のシェルとコプロセスの間に双方向パイプが確立される。 | 
|  |        asynchronously  in a subshell, as if the command had been terminated with the &control operator,
 |  | 
|  |        with a two-way pipe established between the executing shell and the coprocess.
 |  | 
|  | 
 |  | 
 | 
|  |        The format for a coprocess is:
 |  | コプロセスの書式は以下の通りである: | 
|  | 
 |  | 
 | 
|  |               coproc [NAME] command [redirections]
 |  | :<nowiki>coproc [NAME] command [redirections]</nowiki> | 
|  | 
 |  | 
 | 
|  |        This creates a coprocess named NAME. If NAME is not supplied, the default name is COPROC.   NAME
 |  | これはNAMEという名前のコプロセスを作成する。 NAME が与えられない場合、デフォルトの名前は COPROC である。  NAME は、 command が単純コマンド(上記を参照のこと)の場合は与えてはならない。 コプロセスが実行されると、シェルは実行中のシェルのコンテキスト内に NAME という名前の配列変数(後述の「配列」を参照)を作成する。 コマンドの標準出力は、実行シェルのファイル記述子にパイプで接続され、そのファイル記述子が<nowiki>NAME[0]</nowiki>に代入される。 コマンドの標準入力は、実行シェルのファイル記述子にパイプで接続され、そのファイル記述子が <nowiki>NAME[1]</nowiki>に割り当てられる。  このパイプは、コマンドで指定されたリダイレクション(後述の[[#REDIRECTION|REDIRECTION]]を参照)の前に確立される。 | 
|  |        must  not be supplied if command is a simple command (see above); otherwise, it is interpreted as
 |  | ファイル記述子は、標準的な単語展開を使って、シェルコマンドやリダイレクションの引数として利用できる。 コマンドとプロセス置換を実行するために作成されたもの以外では、ファイル記述子はサブシェルでは利用できない。 コプロセスを実行するために生成されたシェルのプロセス ID は、変数 '''NAME_PID''' の値として利用できる。 wait 組み込みコマンドは、コプロセスの終了を待つために使用できる。 | 
|  |        the first word of the simple command.  When the coprocess is executed, the shell creates an array
 |  | 
|  |        variable  (see Arrays below) named NAMEin the context of the executing shell.  The standard out‐
 |  | 
|  |        put of command is connected via a pipe to a file descriptor in the executing shell, and that file
 |  | 
|  |        descriptor  is  assigned  to NAME[0].  The standard input of command is connected via a pipe to a
 |  | 
|  |        file descriptor in the executing shell, and that file descriptor is assigned  to  NAME[1].   This
 |  | 
|  |        pipe is  established  before  any redirections specified by the command (see REDIRECTIONbelow).
 |  | 
|  |        The file descriptors can be utilized as arguments to shell commands and redirections using  stan‐
 |  | 
|  |        dard word expansions.  Other than those created to execute command and process substitutions, the
 |  | 
|  |        file descriptors are not available in subshells.  The process IDof the shell spawned to  execute
 |  | 
|  |        the  coprocess  is available as the value of the variable NAME_PID.  The wait builtin command may
 |  | 
|  |        be used to waitfor the coprocess to terminate.
 |  | 
|  | 
 |  | 
 | 
|  |        Since the coprocess is created as an asynchronous command, the coproc command always returns suc‐
 |  | コプロセスは非同期コマンドとして作成されるため、coproc コマンドは常に成功を返す。 コプロセスの戻りステータスは、コマンドの終了ステータスである。 | 
|  |        cess.  The return status of a coprocess is the exit status of command.
 |  | 
|  | 
 |  | 
 | 
|  | === Shell Function Definitions === |  | === Shell Function Definitions === |