X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=Documentation%2FCodingGuidelines;h=09ffc46563cba1057b37ba4a5701858fb95c5dda;hb=7e4eb210bdf2a612d8bf4cc106d99ba190f73e3e;hp=b8bf618a30fd32a014e41e1ba9914f5e652bdefd;hpb=3a2dd481e51ed3ea01b84c7db4c661a0a3d5279c;p=git.git diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines index b8bf618a3..09ffc4656 100644 --- a/Documentation/CodingGuidelines +++ b/Documentation/CodingGuidelines @@ -35,21 +35,28 @@ For shell scripts specifically (not exhaustive): properly nests. It should have been the way Bourne spelled it from day one, but unfortunately isn't. - - We use ${parameter-word} and its [-=?+] siblings, and their - colon'ed "unset or null" form. + - We use POSIX compliant parameter substitutions and avoid bashisms; + namely: - - We use ${parameter#word} and its [#%] siblings, and their - doubled "longest matching" form. + - We use ${parameter-word} and its [-=?+] siblings, and their + colon'ed "unset or null" form. - - We use Arithmetic Expansion $(( ... )). + - We use ${parameter#word} and its [#%] siblings, and their + doubled "longest matching" form. + + - No "Substring Expansion" ${parameter:offset:length}. - - No "Substring Expansion" ${parameter:offset:length}. + - No shell arrays. - - No shell arrays. + - No strlen ${#parameter}. - - No strlen ${#parameter}. + - No pattern replacement ${parameter/pattern/string}. + + - We use Arithmetic Expansion $(( ... )). - - No regexp ${parameter/pattern/string}. + - Inside Arithmetic Expansion, spell shell variables with $ in front + of them, as some shells do not grok $((x)) while accepting $(($x)) + just fine (e.g. dash older than 0.5.4). - We do not use Process Substitution <(list) or >(list).