Shell Command Language
The <backslash> and <newline> shall be removed before splitting the input into tokens.
Token Recognize
1. もし入力終了を検知した場合、現在のトークンは区切られる
2. もしひとつ前の文字がoperatorの一部だった場合、そして現在の文字がクオートされておらず、一つ前の文字とともに使われて、operatorを構成する可能性がある場合、operatorトークンの一部として用いられる
3. もし一つ前の文字が、operatorの一部だった場合、そして現在の文字が一つ前の文字とともにoperatorを構成する可能性がない場合、一つ前の文字を含む演算子は区切られる
4. もし現在の文字が<backslash>か、single-quoteか、double-quoteで、かつ引用されてない場合、一連の連続する文字列をquoteする。quotingのルールはQuotingに書かれている。トークン認識において、置換は実施されない.そして、結果トークンは入力に出る実際の文字を含み、修正せず、引用マークの間にある、埋め込みの同封の引用や、置換operatorを含む。引用の終わりまで区切られることはない。
5. もし現在のキャラクタがクオートされていない'$'とか'`'であれば、非引用文字列の開始からshellはparameter展開、あるいはcommand置換、数式拡張候補の開始とみなす。例えば、'$', "${", "$(".Shellは拡張するのに必要な単位を決めるのに十分な入力を読む。文字を処理している間、拡張とかネストした置換が見つかった場合は、shellは再帰的に処理する。
Alias Substitution
After a token has been delimited, but before applying the grammatical rules in Shell Grammar
To prevent infinite loops in recursive aliasing, if the shell is not currently processing an alias of the same name, the word shall be replaced by the value of the alias; otherwise, it shall not be replaced.
2.4 Reserved Words
https://gyazo.com/79526936906d402b8f14d4033dbbec6d
The following words may be recognized as reserved words on some implementations (when none of the characters are quoted), causing unspecified results:
https://gyazo.com/3b2415c22277a9ea9aebd03abb8da41e
2.5 Parameters and Variables
PPID
Set by the shell to the decimal value of its parent process ID during initialization of the shell. In a subshell (see Shell Execution Environment), PPID shall be set to the same value as that of the parent of the current shell. For example, echo $ PPID and (echo $ PPID) would produce the same value.
1. Tilde expansion (see Tilde Expansion), parameter expansion (see Parameter Expansion), command substitution (see Command Substitution), and arithmetic expansion (see Arithmetic Expansion) shall be performed, beginning to end. See item 5 in Token Recognition.
2. Field splitting (see Field Splitting) shall be performed on the portions of the fields generated by step 1, unless IFS is null.
3. Pathname expansion (see Pathname Expansion) shall be performed, unless set -f is in effect.
4. Quote removal (see Quote Removal) shall always be performed last.
Use Default Values. If parameter is unset or null, the expansion of word (or an empty string if word is omitted) shall be substituted; otherwise, the value of parameter shall be substituted.
Assign Default Values. If parameter is unset or null, the expansion of word (or an empty string if word is omitted) shall be assigned to parameter. In all cases, the final value of parameter shall be substituted. Only variables, not positional parameters or special parameters, can be assigned in this way.
Indicate Error if Null or Unset. If parameter is unset or null, the expansion of word (or a message indicating it is unset if word is omitted) shall be written to standard error and the shell exits with a non-zero exit status. Otherwise, the value of parameter shall be substituted. An interactive shell need not exit.
Use Alternative Value. If parameter is unset or null, null shall be substituted; otherwise, the expansion of word (or an empty string if word is omitted) shall be substituted.
${#parameter}
String Length. The length in characters of the value of parameter shall be substituted. If parameter is '*' or '@', the result of the expansion is unspecified. If parameter is unset and set -u is in effect, the expansion shall fail.
https://gyazo.com/2147948b741fb461df120f4bb1d4ae1d
2.6.5 Field Splittingまで