CodingGuidelines: give an example for control statements
Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
6a49909b52
commit
9dbe780174
|
@ -107,6 +107,17 @@ For shell scripts specifically (not exhaustive):
|
||||||
"then" should be on the next line for if statements, and "do"
|
"then" should be on the next line for if statements, and "do"
|
||||||
should be on the next line for "while" and "for".
|
should be on the next line for "while" and "for".
|
||||||
|
|
||||||
|
(incorrect)
|
||||||
|
if test -f hello; then
|
||||||
|
do this
|
||||||
|
fi
|
||||||
|
|
||||||
|
(correct)
|
||||||
|
if test -f hello
|
||||||
|
then
|
||||||
|
do this
|
||||||
|
fi
|
||||||
|
|
||||||
- We prefer "test" over "[ ... ]".
|
- We prefer "test" over "[ ... ]".
|
||||||
|
|
||||||
- We do not write the noiseword "function" in front of shell
|
- We do not write the noiseword "function" in front of shell
|
||||||
|
|
Loading…
Reference in New Issue