Skip to content

Commit 7dbe8c8

Browse files
tboegigitster
authored andcommitted
check-non-portable-shell.pl: wc -l may have leading WS
Test scripts count number of lines in an output and check it againt its expectation. fb3340a ("test-lib: introduce test_line_count to measure files", 2010-10-31) introduced a helper to show a failure in such a test in a more readable way than comparing `wc -l` output with a number. Besides, on some platforms, "$(wc -l <file)" is padded with leading whitespace on the left, so test "$(wc -l <file)" = 4 would not work (most notably on macosX); the users of test_line_count helper would not suffer from such a portability glitch. Add a check in check-non-portable-shell.pl to find '"' between `wc -l` and '=' and hint the user about test_line_count(). Signed-off-by: Torsten Bögershausen <[email protected]> Reviewed-by: Johannes Schindelin <[email protected]> Helped-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 936d1b9 commit 7dbe8c8

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

t/check-non-portable-shell.pl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ sub err {
2121
/^\s*declare\s+/ and err 'arrays/declare not portable';
2222
/^\s*[^#]\s*which\s/ and err 'which is not portable (please use type)';
2323
/\btest\s+[^=]*==/ and err '"test a == b" is not portable (please use =)';
24+
/\bwc -l.*"\s*=/ and err '`"$(wc -l)"` is not portable (please use test_line_count)';
2425
/\bexport\s+[A-Za-z0-9_]*=/ and err '"export FOO=bar" is not portable (please use FOO=bar && export FOO)';
2526
# this resets our $. for each file
2627
close ARGV if eof;

0 commit comments

Comments
 (0)