From: Elia Pinto Date: Fri, 06 Jun 2014 14:56:03 GMT Subject: [PATCH 20/20] CodingGuidelines: avoid "test -a/-o " Message-ID: <1402066563-28519-21-git-send-email-gitter.spiros@gmail.com> In-Reply-To: <1402066563-28519-1-git-send-email-gitter.spiros@gmail.com> The construct is error-prone; "test" being built-in in most modern shells, the reason to avoid "test && test " spawning one extra process by using a single "test -a " no longer exists. Signed-off-by: Junio C Hamano Signed-off-by: Elia Pinto --- Documentation/CodingGuidelines | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines index f424dbd..2d426bc 100644 --- a/Documentation/CodingGuidelines +++ b/Documentation/CodingGuidelines @@ -106,6 +106,18 @@ 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 -- 1.7.10.4