Debian Live マニュアル 日本語版live-helperを使うついでに日本語版も作成開始しました。内容は確認しながら、やっていますがほとんど意訳なので翻訳の正確さは保障いたしません。

×
10 コーディングスタイル

This chapter documents the coding style used in live-helper and
(ideally) in live-initramfs.

10.1. Compatibility
* Don't use syntax or semantics that are unique to the Bash shell. For example, the use of array constructs. * Only use the POSIX subset - for example, use $(foo) over `foo`. * You can check your scripts with 'sh -n' and 'checkbashisms'

10.2. Indenting
* Always use tabs over spaces.

10.3. Wrapping
* Generally, lines are 80 chars at maximum. * Use the "Linux style" of line breaks:
Bad:
if foo; then bar fi
Good:
if foo then bar fi
* The same holds for functions:
Bad:
foo () { bar }
Good:
foo () { bar }


10.4. Variables
* Variables are always in capital letters. * Variables that used in config always start with LH_ prefix. * Internal temporary variables should start with the _LH_ prefix. * Local variables start with __LH_ prefix. * Use braces around variables; eg. write ${FOO} instead of $FOO. * Always protect variables with respect to potential whitespaces, write "${FOO}" not ${FOO}. * For consistency reasons, always use quotes when assigning values to variables:
Bad:
FOO=bar
Good:
FOO="bar"
* If multiple variables are used, quote the full expression:
Bad:
if [ -f "${FOO}"/foo/"${BAR}"/bar ] then foobar fi
Good:
if [ -f "${FOO}/foo/${BAR}/bar" ] then foobar fi


10.5. Miscellaneous
* Use "|" (without the surround quotes) as a seperator in calls to sed, e.g. "sed -e 's|foo|bar|'" (without ""). * Don't use the test command for comparisons or tests, use "[" "]" (without ""), e.g. "if [ -x /bin/foo ]; ..." and not "if test -x /bin/foo; ...".

このページへのコメント

dqJPIS Im obliged for the article post.Really thank you! Great.

0
Posted by watch for this 2013年12月21日(土) 13:44:45 返信

コメントをかく


「http://」を含む投稿は禁止されています。

利用規約をご確認のうえご記入下さい

Wiki内検索

Menu

ここは自由に編集できるエリアです。

メンバーのみ編集できます

広告募集中