Skip to content

Commit

Permalink
Documentation/CodingGuidelines: spell out more shell guidelines
Browse files Browse the repository at this point in the history
In earlier days, "imitate the style in the neibouring code" was
sufficient to keep the coherent style, but over time some parts of
the codebase have drifted enough to make it ineffective.

Spell some of the guidelines out.

Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Heiko Voigt authored and Junio C Hamano committed Aug 15, 2012
1 parent b0fa280 commit 03b05c7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Documentation/CodingGuidelines
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,19 @@ For shell scripts specifically (not exhaustive):

- We do not use Process Substitution <(list) or >(list).

- Do not write control structures on a single line with semicolon.
"then" should be on the next line for if statements, and "do"
should be on the next line for "while" and "for".

- We prefer "test" over "[ ... ]".

- We do not write the noiseword "function" in front of shell
functions.

- We prefer a space between the function name and the parentheses. The
opening "{" should also be on the same line.
E.g.: my_function () {

- As to use of grep, stick to a subset of BRE (namely, no \{m,n\},
[::], [==], nor [..]) for portability.

Expand Down

0 comments on commit 03b05c7

Please sign in to comment.