From: Torsten Bögershausen Date: Sun, 13 Jan 2013 10:25:57 GMT Subject: Re: [PATCH] tests: turn on test-lint-shell-syntax by default Message-ID: <50F28BB5.9080607@web.de> In-Reply-To: <7vvcb37xfe.fsf@alter.siamese.dyndns.org> On 12.01.13 07:00, Junio C Hamano wrote: > Torsten Bögershausen writes: > >> The test Makefile has a default set of lint tests which are run >> as part of "make test". >> >> The macro TEST_LINT defaults to "test-lint-duplicates test-lint-executable". >> >> Add test-lint-shell-syntax here, to detect non-portable shell syntax early. >> >> Signed-off-by: Torsten Bögershausen >> --- > > As I said already, I do not want to do this yet without further > reduction of false positives. Which reinds me that the expression fishing for "which" is really poor. How about something like the following: -- >8 -- Subject: [PATCH] Reduce false positive in check-non-portable-shell.pl check-non-portable-shell.pl is using simple regular expressions to find illegal shell syntax. Improve the expressions and reduce the chance for false positves: "sed -i" must be followed by 1..n whitespace and 1 non whitespace "declare" must be followed by 1..n whitespace and 1 non whitespace "echo -n" must be followed by 1..n whitespace and 1 non whitespace "which" must be followed by 1..n whitespace, a string, "end of line" diff --git a/t/check-non-portable-shell.pl b/t/check-non-portable-shell.pl index 8b5a71d..7151dd6 100755 --- a/t/check-non-portable-shell.pl +++ b/t/check-non-portable-shell.pl @@ -16,10 +16,10 @@ sub err { while (<>) { chomp; - /^\s*sed\s+-i/ and err 'sed -i is not portable'; - /^\s*echo\s+-n/ and err 'echo -n is not portable (please use printf)'; - /^\s*declare\s+/ and err 'arrays/declare not portable'; - /^\s*[^#]\s*which\s/ and err 'which is not portable (please use type)'; + /^\s*sed\s+-i\s+\S/ and err 'sed -i is not portable'; + /^\s*echo\s+-n\s+\S/ and err 'echo -n is not portable (please use printf)'; + /^\s*declare\s+\S/ and err 'arrays/declare not portable'; + /^\s*[^#]\s*which\s+[-a-zA-Z0-9]+$/ and err 'which is not portable (please use type)'; /test\s+[^=]*==/ and err '"test a == b" is not portable (please use =)'; # this resets our $. for each file close ARGV if eof;