summaryrefslogtreecommitdiff
path: root/Documentation/CodingGuidelines
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-05-20 18:12:02 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-05-20 18:19:43 (GMT)
commit897f964c0dce8e7cc2cc53bb19b83cadce106773 (patch)
tree06125e26e6ee2c83b70e1739aa323efab225c599 /Documentation/CodingGuidelines
parentf26443da0449c459dab8b91d963bd91dd4335657 (diff)
downloadgit-897f964c0dce8e7cc2cc53bb19b83cadce106773.zip
git-897f964c0dce8e7cc2cc53bb19b83cadce106773.tar.gz
git-897f964c0dce8e7cc2cc53bb19b83cadce106773.tar.bz2
CodingGuidelines: avoid "test <cond> -a/-o <cond>"
The construct is error-prone; "test" being built-in in most modern shells, the reason to avoid "test <cond> && test <cond>" spawning one extra process by using a single "test <cond> -a <cond>" no longer exists. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Documentation/CodingGuidelines')
-rw-r--r--Documentation/CodingGuidelines13
1 files changed, 13 insertions, 0 deletions
diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 3d08671..4d90c77 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -151,6 +151,19 @@ For shell scripts specifically (not exhaustive):
interface translatable. See "Marking strings for translation" in
po/README.
+ - We do not write our "test" command with "-a" and "-o" and use "&&"
+ or "||" to concatenate multiple "test" commands instead, because
+ the use of "-a/-o" is often error-prone. E.g.
+
+ test -n "$x" -a "$a" = "$b"
+
+ is buggy and breaks when $x is "=", but
+
+ test -n "$x" && test "$a" = "$b"
+
+ does not have such a problem.
+
+
For C programs:
- We use tabs to indent, and interpret tabs as taking up to