/usr/bin/bash: Difference between revisions

Line 784: Line 784:


=== Word Splitting ===
=== Word Splitting ===
      The shell scans the results of parameter expansion, command substitution, and  arithmetic  expan‐
シェルは、パラメータ展開、コマンド置換、算術展開の結果のうち、二重引用符で囲まれていないものを、単語分割のためにスキャンする。
      sion that did not occur within double quotes for word splitting.


      The shell treats each character of IFS as a delimiter, and splits the results of the other expan‐
シェルはIFSの各文字を区切り文字として扱い、これらの文字をフィールドの終端文字として、他の展開の結果を単語に分割する。 IFSが設定されていないか、またはその値がデフォルトの<space><tab><newline>の場合、以前の展開結果の先頭と末尾にある<space><tab><newline>のシーケンスは無視され、先頭と末尾にないIFS文字のシーケンスは単語を区切る役割を果たす。 IFSの値がデフォルト以外の場合、単語の先頭と末尾にある空白文字スペース、タブ、改行のシーケンスは、空白文字がIFSの値(IFS空白文字)にある限り無視される。 IFSの空白文字以外の文字は、隣接するIFSの空白文字とともに、フィールドを区切る。 IFS空白文字の連続も区切り文字として扱われる。 IFSの値がNULLの場合、単語の分割は行われない。
      sions into words using these characters as field terminators.  If IFS is unset, or its  value  is
      exactly  <space><tab><newline>,  the  default, then sequences of <space>, <tab>, and <newline> at
      the beginning and end of the results of the previous expansions are ignored, and any sequence  of
      IFS  characters  not  at  the beginning or end serves to delimit words.  If IFS has a value other
      than the default, then sequences of the whitespace characters space, tab, and newline are ignored
      at  the beginning and end of the word, as long as the whitespace character is in the value of IFS
      (an IFS whitespace character).  Any character in IFS that is not IFS whitespace, along  with  any
      adjacent IFS whitespace characters, delimits a field.  A sequence of IFS whitespace characters is
      also treated as a delimiter.  If the value of IFS is null, no word splitting occurs.


      Explicit null arguments ("" or '') are retained and passed to commands as empty  strings.  Un‐
明示的NULL引数(""または'')は保持され、空文字列としてコマンドに渡される。 引用符で囲まれていない暗黙のNULL引数は、値を持たないパラメータが展開された結果、削除される。 値を持たないパラメータが二重引用符で囲まれて展開された場合、NULL引数が保持され、空文字列としてコマンドに渡される。 引用符で囲まれたNULL引数が、NULLでない単語の展開の一部として現れると、NULL引数は削除される。 つまり、単語-d''は、単語分割とNULL引数除去の後、-dになる。
      quoted  implicit  null arguments, resulting from the expansion of parameters that have no values,
      are removed.  If a parameter with no value is expanded within double quotes, a null argument  re‐
      sults  and  is  retained and passed to a command as an empty string.  When a quoted null argument
      appears as part of a word whose expansion is non-null, the null argument is  removed.  That  is,
      the word -d'' becomes -d after word splitting and null argument removal.


      Note that if no expansion occurs, no splitting is performed.
展開が行われない場合、分割は行われない。


=== Pathname Expansion ===
=== Pathname Expansion ===