シェルスクリプト総合 その29at TECH
シェルスクリプト総合 その29 - 暇つぶし2ch636:デフォルトの名無しさん
18/11/15 11:23:09.13 gWaB1LhD0.net
URLリンク(pubs.opengroup.org)
に書いてあるだろ
> Arithmetic expansion provides a mechanism for evaluating an arithmetic expression and substituting its value.
> The format for arithmetic expansion shall be as follows:
>
> $((expression))
>
> The expression shall be treated as if it were in double-quotes, except that a double-quote inside
> the expression is not treated specially. The shell shall expand all tokens in the expression for
> parameter expansion, command substitution, and quote removal.
まず、$(( )) の中にある。これがexpressionだ。
expand all tokens in the expression 式の中にある以下のトークンの展開、
for parameter expansion, command substitution, and quote removal.
パラメータ展開、コマンド置換、クォートの削除
> Next, the shell shall treat this as an arithmetic expression and substitute the value of the expression.
その次(Next)に この式を arithmetic expression (算術式)として扱う
つまりだ。パラメータ展開( $(($x))の$xの展開 )が行われるまでは、まだ算術式として扱う前なんだよ
そもそもだな。 x=123を見て分かる通り。変数名はxだぞ。$xじゃない。
他の言語では変数名が$で始まるものがあるが、シェルスクリプトにおいて、
$は、パラメータ展開、コマンド置換、算術展開等を行うための記号だって書いてあるだろ?
特殊変数の説明だって、$@じゃなくて@、$*じゃなくて*、$#じゃなくて#、$$じゃなくて$ と書いており
変数名とは最初の$は含まれない部分だってことが読み取れるだろ


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch