「Transwiki:Bash Shell Scripting」の版間の差分

削除された内容 追加された内容
Fu7mu4 (トーク | 投稿記録)
Fu7mu4 (トーク | 投稿記録)
583 行
 
* <tt>then</tt> または <tt>else</tt>のあとに改行文字を入れます。この改行文字はオプションです。-- この改行はセミコロンに置き換えられません -- しかし改行文字によって <tt>if</tt> ステートメントの読み易さ、リーダビリティに貢献しています。
* 通常のコマンドは改行で区切り、セミコロンは使用しません。これは一般的な規約で<tt>if</tt>ステートメントに限られるものではありません。各行にコマンドを配置することで、他のひとがそのスクリプトがなにをしているのかをざっくりと把握することができるようになります。
* Regular commands are separated by newlines, never semicolons. This is a general convention, not specific to <tt>if</tt> statements. Putting each command on its own line makes it easier for someone to "skim" the script and see roughly what it is doing.
 
これらの正格な規約は特に重要ではありません。しかし規約は一貫して従うことがよくコードを規約に従って読み易くしましょう。あなたのコードを熟練プログラマが見たとき、または書き上げたあなたが数ヶ月後にそれを見返したとき、一貫性のなさやフォーマットの違反があるとスクリプトが何をしているかがわかりにくくさせる原因です。
These exact conventions are not particularly important, but it is good to follow consistent and readable conventions for formatting your code. When a fellow programmer looks at your code — or when you look at your code two months after writing it — inconsistent or illogical formatting can make it very difficult to understand what is going on.
 
==反復・ループ==