Patchwork [2,of,2] check-code: ban use of '[[ ]]' in tests

login
register
mail settings
Submitter Yuya Nishihara
Date June 16, 2015, 3:11 p.m.
Message ID <e321716cab1d0cec13a6.1434467517@mimosa>
Download mbox | patch
Permalink /patch/9669/
State Accepted
Headers show

Comments

Yuya Nishihara - June 16, 2015, 3:11 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1434463590 -32400
#      Tue Jun 16 23:06:30 2015 +0900
# Node ID e321716cab1d0cec13a6cc3613d8201b4f34f7d9
# Parent  058a621cadbfcfbd53fb40d0b6b65074b8919b37
check-code: ban use of '[[ ]]' in tests
Pierre-Yves David - June 16, 2015, 8:48 p.m.
On 06/16/2015 08:11 AM, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1434463590 -32400
> #      Tue Jun 16 23:06:30 2015 +0900
> # Node ID e321716cab1d0cec13a6cc3613d8201b4f34f7d9
> # Parent  058a621cadbfcfbd53fb40d0b6b65074b8919b37
> check-code: ban use of '[[ ]]' in tests

Good catch,

I've these two are pushed to the clowncopter.

Thanks.

Patch

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -114,6 +114,7 @@  testpats = [
     (r'[^>\n]>\s*\$HGRCPATH', "don't overwrite $HGRCPATH, append to it"),
     (r'^stop\(\)', "don't use 'stop' as a shell function name"),
     (r'(\[|\btest\b).*-e ', "don't use 'test -e', use 'test -f'"),
+    (r'\[\[\s+[^\]]*\]\]', "don't use '[[ ]]', use '[ ]'"),
     (r'^alias\b.*=', "don't use alias, use a function"),
     (r'if\s*!', "don't use '!' to negate exit status"),
     (r'/dev/u?random', "don't use entropy, use /dev/zero"),