[表示 : 全て 最新50 1-99 101- 201- 301- 401- 501- 601- 701- 801- 901- 2ch.scのread.cgiへ]
Update time : 01/12 09:15 / Filesize : 284 KB / Number-of Response : 907
[このスレッドの書き込みを削除する]
[+板 最近立ったスレ&熱いスレ一覧 : +板 最近立ったスレ/記者別一覧] [類似スレッド一覧]


↑キャッシュ検索、類似スレ動作を修正しました、ご迷惑をお掛けしました

シェルスクリプト総合 その29



636 名前:デフォルトの名無しさん mailto:sage [2018/11/15(木) 11:23:09.13 ID:gWaB1LhD0.net]
pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_04_01
に書いてあるだろ

> 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じゃない。
他の言語では変数名が$で始まるものがあるが、シェルスクリプトにおいて、
$は、パラメータ展開、コマンド置換、算術展開等を行うための記号だって書いてあるだろ?

特殊変数の説明だって、$@じゃなくて@、$*じゃなくて*、$#じゃなくて#、$$じゃなくて$ と書いており
変数名とは最初の$は含まれない部分だってことが読み取れるだろ






[ 続きを読む ] / [ 携帯版 ]

全部読む 前100 次100 最新50 [ このスレをブックマーク! 携帯に送る ] 2chのread.cgiへ
[+板 最近立ったスレ&熱いスレ一覧 : +板 最近立ったスレ/記者別一覧]( ´∀`)<284KB

read.cgi ver5.27 [feat.BBS2 +1.6] / e.0.2 (02/09/03) / eucaly.net products.
担当:undef