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>
Junio C Hamano committed
Oct 13, 2010 at 11:15 UTC
bc979945305b87caf1e5975d30d42bafd88ad846
1 file changed
+15
-12
Documentation/CodingGuidelines
+15
-12
@@ -35,25 +35,28 @@ For shell scripts specifically (not exhaustive):
35
properly nests. It should have been the way Bourne spelled
36
it from day one, but unfortunately isn't.
37
38
- - We use ${parameter-word} and its [-=?+] siblings, and their
39
- colon'ed "unset or null" form.
38
+ - We use POSIX compliant parameter substitutions and avoid bashisms;
39
+ namely:
40
41
- - We use ${parameter#word} and its [#%] siblings, and their
42
- doubled "longest matching" form.
41
+ - We use ${parameter-word} and its [-=?+] siblings, and their
42
+ colon'ed "unset or null" form.
43
44
- - We use Arithmetic Expansion $(( ... )).
44
+ - We use ${parameter#word} and its [#%] siblings, and their
45
+ doubled "longest matching" form.
46
46
- - Inside Arithmetic Expansion, spell shell variables with $ in front
47
- of them, as some shells do not grok $((x)) while accepting $(($x))
48
- just fine (e.g. dash older than 0.5.4).
47
+ - No "Substring Expansion" ${parameter:offset:length}.
48
50
- - No "Substring Expansion" ${parameter:offset:length}.
49
+ - No shell arrays.
50
52
- - No shell arrays.
51
+ - No strlen ${#parameter}.
52
54
- - No strlen ${#parameter}.
53
+ - No pattern replacement ${parameter/pattern/string}.
54
56
- - No regexp ${parameter/pattern/string}.
55
+ - We use Arithmetic Expansion $(( ... )).
56
+
57
+ - Inside Arithmetic Expansion, spell shell variables with $ in front
58
+ of them, as some shells do not grok $((x)) while accepting $(($x))
59
+ just fine (e.g. dash older than 0.5.4).
60
61
- We do not use Process Substitution <(list) or >(list).
62