シェルスクリプト総合 その33at TECHシェルスクリプト総合 その33 - 暇つぶし2ch■コピペモード□スレを通常表示□オプションモード□このスレッドのURL■項目テキスト32:デフォルトの名無しさん 20/03/28 14:59:32.82 Bw1KM2rM.net >>31 POSIXでどこまで決まってるか知らんけど、 ふる~いdashでは失敗する 33:デフォルトの名無しさん 20/03/28 15:06:39.27 Bw1KM2rM.net あと $((i = 1)) とか $((i++)) とかも使えるよ 注意点としては i=0 while [ "$i" -lt 100 ]; do は iは0から始まるが while [ $((i+=)) -lt 100 ]; do だとiは1からになるって所だな 34:デフォルトの名無しさん 20/03/28 15:16:54.38 KzFz1ENP.net >>33 $((i++))という書き方は,少なくともPOSIXでは保証されてない。 https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_04 35:デフォルトの名無しさん 20/03/28 16:41:52 55WldctP.net >>34 本当に? https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap01.html#tag_17_01_02_01 36:デフォルトの名無しさん 20/03/28 16:49:31 KzFz1ENP.net >>35 本当です。 2.6.4 Arithmetic Expansion ... The arithmetic expression shall be processed according to the rules given in Arithmetic Precision and Operations, with the following exceptions: * The sizeof() operator and the prefix and postfix "++" and "--" operators are not required. ちゃんと読みましょう。 次ページ最新レス表示レスジャンプ類似スレ一覧スレッドの検索話題のニュースおまかせリストオプションしおりを挟むスレッドに書込スレッドの一覧暇つぶし2ch