Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
CodingGuidelines: avoid "test <cond> -a/-o <cond>"
author
Junio C Hamano
<gitster@pobox.com>
Tue, 20 May 2014 18:12:02 +0000
(11:12 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Tue, 20 May 2014 18:19:43 +0000
(11:19 -0700)
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>
Documentation/CodingGuidelines
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
f26443d
)
diff --git
a/Documentation/CodingGuidelines
b/Documentation/CodingGuidelines
index 3d08671ad3fee3bbe2a3af7332080145a15dfc0a..4d90c77c7bd643b11df8d3094efe142493df53b9 100644
(file)
--- 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.
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
For C programs:
- We use tabs to indent, and interpret tabs as taking up to