Submitter | Augie Fackler |
---|---|
Date | May 15, 2017, 6:09 p.m. |
Message ID | <cce0fa53cc1401b5bb23.1494871754@augie-macbookpro2.roam.corp.google.com> |
Download | mbox | patch |
Permalink | /patch/20631/ |
State | Accepted |
Headers | show |
Comments
Seems a good exercise for greg and smf. Excerpts from Augie Fackler's message of 2017-05-15 14:09:14 -0400: > # HG changeset patch > # User Augie Fackler <augie@google.com> > # Date 1494871682 14400 > # Mon May 15 14:08:02 2017 -0400 > # Node ID cce0fa53cc1401b5bb234acc3e846f0595febe4b > # Parent 366db10cb40f7fb1b804bfc87c8767d79a876489 > style: ban [ foo == bar] bashism in tests > > diff --git a/contrib/check-code.py b/contrib/check-code.py > --- a/contrib/check-code.py > +++ b/contrib/check-code.py > @@ -116,6 +116,7 @@ testpats = [ > (r'printf.*[^\\]\\x', "don't use printf \\x, use Python"), > (r'\$\(.*\)', "don't use $(expr), use `expr`"), > (r'rm -rf \*', "don't use naked rm -rf, target a directory"), > + (r'\[[^\]]+==', '[ foo == bar ] is a bashism, use [ foo = bar ] instead'), > (r'(^|\|\s*)grep (-\w\s+)*[^|]*[(|]\w', > "use egrep for extended grep syntax"), > (r'/bin/', "don't use explicit paths for tools"), > diff --git a/tests/test-contrib-check-code.t b/tests/test-contrib-check-code.t > --- a/tests/test-contrib-check-code.t > +++ b/tests/test-contrib-check-code.t > @@ -152,6 +152,15 @@ > > $ function onwarn {} > warning: don't use 'function', use old style > [1] > + $ cat > error.t <<EOF > + > $ [ foo == bar ] > + > EOF > + $ "$check_code" error.t > + error.t:1: > + > $ [ foo == bar ] > + [ foo == bar ] is a bashism, use [ foo = bar ] instead > + [1] > + $ rm error.t > $ cat > raise-format.py <<EOF > > raise SomeException, message > > # this next line is okay
Jun Wu <quark@fb.com> writes:
> Seems a good exercise for greg and smf.
Sure, queued again!
Patch
diff --git a/contrib/check-code.py b/contrib/check-code.py --- a/contrib/check-code.py +++ b/contrib/check-code.py @@ -116,6 +116,7 @@ testpats = [ (r'printf.*[^\\]\\x', "don't use printf \\x, use Python"), (r'\$\(.*\)', "don't use $(expr), use `expr`"), (r'rm -rf \*', "don't use naked rm -rf, target a directory"), + (r'\[[^\]]+==', '[ foo == bar ] is a bashism, use [ foo = bar ] instead'), (r'(^|\|\s*)grep (-\w\s+)*[^|]*[(|]\w', "use egrep for extended grep syntax"), (r'/bin/', "don't use explicit paths for tools"), diff --git a/tests/test-contrib-check-code.t b/tests/test-contrib-check-code.t --- a/tests/test-contrib-check-code.t +++ b/tests/test-contrib-check-code.t @@ -152,6 +152,15 @@ > $ function onwarn {} warning: don't use 'function', use old style [1] + $ cat > error.t <<EOF + > $ [ foo == bar ] + > EOF + $ "$check_code" error.t + error.t:1: + > $ [ foo == bar ] + [ foo == bar ] is a bashism, use [ foo = bar ] instead + [1] + $ rm error.t $ cat > raise-format.py <<EOF > raise SomeException, message > # this next line is okay