/usr/bin/bash: Difference between revisions

Line 931: Line 931:


=== Here Documents ===
=== Here Documents ===
      This  type  of redirection instructs the shell to read input from the current source until a line
このタイプのリダイレクトは、区切り文字(末尾に空白を含まない)だけを含む行が表示されるまで、現在のソースから入力を読み込むようにシェルに指示する。 その時点までに読み込まれたすべての行が、コマンドの標準入力(nが指定されている場合はファイル記述子n)として使用される。
      containing only delimiter (with no trailing blanks) is seen.  All of the lines read  up  to  that
      point are then used as the standard input (or file descriptor n if n is specified) for a command.


      The format of here-documents is:
here-documentsの書式は以下の通りである:


<syntaxhighlight lang="bash">
               [n]<<[-]word
               [n]<<[-]word
                       here-document
                       here-document
               delimiter
               delimiter
</syntaxhighlight>


      No  parameter and variable expansion, command substitution, arithmetic expansion, or pathname ex‐
wordに対してパラメータや変数の展開、コマンドの置換、算術展開、パス名の展開は行われない。 word の一部が引用符で囲まれている場合、区切り文字は word の引用符除去の結果となり、 ヒアドキュメントの行は展開されない。 wordが引用符で囲まれていない場合、ヒアドキュメントのすべての行はパラメータ展開、コマンド置換、および算術展開の対象となり、文字シーケンスである<nowiki>\<newline></nowiki>は無視され、<nowiki>\, $</nowiki>、および`は引用符で囲むために使用されなければならない。
      pansion is performed on word.  If any part of word is quoted, the  delimiter  is  the  result  of
      quote removal on word, and the lines in the here-document are not expanded.  If word is unquoted,
      all lines of the here-document are subjected to parameter expansion,  command  substitution,  and
      arithmetic  expansion,  the character sequence \<newline> is ignored, and \ must be used to quote
      the characters \, $, and `.


      If the redirection operator is <<-, then all leading tab characters are stripped from input lines
リダイレクト演算子が<nowiki><<-</nowiki>の場合、入力行と区切り文字を含む行から先頭のタブ文字がすべて取り除かれる。 これにより、シェルスクリプト内のヒアドキュメントが自然な形でインデントされる。
      and  the  line  containing  delimiter.  This allows here-documents within shell scripts to be in‐
      dented in a natural fashion.


=== Here Strings ===
=== Here Strings ===