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>
This commit is contained in:
Junio C Hamano 2010-10-13 11:15:14 -07:00
parent 537497be58
commit bc97994530

View File

@ -35,11 +35,22 @@ For shell scripts specifically (not exhaustive):
properly nests. It should have been the way Bourne spelled properly nests. It should have been the way Bourne spelled
it from day one, but unfortunately isn't. it from day one, but unfortunately isn't.
- We use ${parameter-word} and its [-=?+] siblings, and their - We use POSIX compliant parameter substitutions and avoid bashisms;
colon'ed "unset or null" form. namely:
- We use ${parameter#word} and its [#%] siblings, and their - We use ${parameter-word} and its [-=?+] siblings, and their
doubled "longest matching" form. colon'ed "unset or null" form.
- We use ${parameter#word} and its [#%] siblings, and their
doubled "longest matching" form.
- No "Substring Expansion" ${parameter:offset:length}.
- No shell arrays.
- No strlen ${#parameter}.
- No pattern replacement ${parameter/pattern/string}.
- We use Arithmetic Expansion $(( ... )). - We use Arithmetic Expansion $(( ... )).
@ -47,14 +58,6 @@ For shell scripts specifically (not exhaustive):
of them, as some shells do not grok $((x)) while accepting $(($x)) of them, as some shells do not grok $((x)) while accepting $(($x))
just fine (e.g. dash older than 0.5.4). just fine (e.g. dash older than 0.5.4).
- No "Substring Expansion" ${parameter:offset:length}.
- No shell arrays.
- No strlen ${#parameter}.
- No regexp ${parameter/pattern/string}.
- We do not use Process Substitution <(list) or >(list). - We do not use Process Substitution <(list) or >(list).
- We prefer "test" over "[ ... ]". - We prefer "test" over "[ ... ]".