summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-10-13 18:15:14 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-10-13 18:15:14 (GMT)
commitbc979945305b87caf1e5975d30d42bafd88ad846 (patch)
tree0b7ff176b65ed3d31f146a66db74ca8c44d8f31b
parent537497be58850dc9c54281d0306b422ab604cdee (diff)
downloadgit-bc979945305b87caf1e5975d30d42bafd88ad846.zip
git-bc979945305b87caf1e5975d30d42bafd88ad846.tar.gz
git-bc979945305b87caf1e5975d30d42bafd88ad846.tar.bz2
CodingGuidelines: reword parameter expansion section
Group entries related to parameter substitutions together and avoid using the word "regexp" to refer to the ${parameter/pattern/string} substitution (banned), as the pattern there is a shell glob and not a regular expression. Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--Documentation/CodingGuidelines27
1 files changed, 15 insertions, 12 deletions
diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 8346c19..09ffc46 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -35,25 +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.
- - 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).
+ - 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}.
- - No regexp ${parameter/pattern/string}.
+ - We use Arithmetic Expansion $(( ... )).
+
+ - 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).