/usr/bin/dash: Difference between revisions

 
Line 369: Line 369:


=== Word Expansions ===
=== Word Expansions ===
    This clause describes the various expansions that are performed on words.  Not all expansions are per‐
この節では、単語に対して行われる様々な展開について説明する。 後述するように、すべての展開がすべての単語に対して行われるわけではない。
    formed on every word, as explained later.
後述するように、すべての単語に適用されるわけではない。


    Tilde expansions, parameter expansions, command substitutions, arithmetic expansions, and quote re‐
チルダ展開、パラメータ展開、コマンド置換、算術展開、引用符除去のうち、1つの単語内で行われるものは、1つのフィールドに展開される。 一つの単語から複数のフィールドを作ることができるのは、フィールドの分割かパス名の展開だけである。 このルールの唯一の例外は、上で説明したように、ダブルクォート内での特殊パラメータ@の展開である。
    movals that occur within a single word expand to a single field.  It is only field splitting or path‐
    name expansion that can create multiple fields from a single word.  The single exception to this rule
    is the expansion of the special parameter @ within double-quotes, as was described above.


    The order of word expansion is:
単語展開の順序は以下の通りである:


    1.  Tilde Expansion, Parameter Expansion, Command Substitution, Arithmetic Expansion (these all occur
#チルダ展開、パラメータ展開、コマンド置換、算術展開(これらはすべて同時に行われる)。
          at the same time).
#フィールド分割は、IFS変数がNULLでない限り、ステップ(1)で生成されたフィールドに対して行われる。
#パス名展開(set -fが有効な場合を除く)。
#引用符の除去。


    2.  Field Splitting is performed on fields generated by step (1) unless the IFS variable is null.
文字は、パラメータ展開、コマンド置換、または算術評価の導入に使用される。


    3.  Pathname Expansion (unless set -f is in effect).
チルダ展開(ユーザーのホームディレクトリを置換する)。
 
引用符で囲まれていないチルダ文字(~)で始まる単語は、チルダ展開の対象となる。 スラッシュ(/)または語尾までのすべての文字がユーザー名として扱われ、そのユーザーのホームディレクトリに置き換えられる。 ユーザー名がない場合(~/foobarのように)、チルダはHOME変数の値(現在のユーザーのホームディレクトリ)に置き換えられる。
    4.  Quote Removal.
 
    The $ character is used to introduce parameter expansion, command substitution, or arithmetic evalua‐
    tion.
 
  Tilde Expansion (substituting a user's home directory)
    A word beginning with an unquoted tilde character (~) is subjected to tilde expansion.  All the char‐
    acters up to a slash (/) or the end of the word are treated as a username and are replaced with the
    user's home directory.  If the username is missing (as in ~/foobar), the tilde is replaced with the
    value of the HOME variable (the current user's home directory).


=== Parameter Expansion ===
=== Parameter Expansion ===