File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ TEST_LINT ?= test-lint-duplicates test-lint-executable
17
17
18
18
# Shell quote;
19
19
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH ) )
20
+ PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH ) )
20
21
21
22
T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-* .sh) )
22
23
TSVN = $(sort $(wildcard t91[0-9][0-9]-* .sh) )
@@ -44,7 +45,7 @@ clean-except-prove-cache:
44
45
clean : clean-except-prove-cache
45
46
$(RM ) .prove
46
47
47
- test-lint : test-lint-duplicates test-lint-executable
48
+ test-lint : test-lint-duplicates test-lint-executable test-lint-shell-syntax
48
49
49
50
test-lint-duplicates :
50
51
@dups=` echo $( T) | tr ' ' ' \n' | sed ' s/-.*//' | sort | uniq -d` && \
@@ -56,6 +57,9 @@ test-lint-executable:
56
57
test -z " $$ bad" || { \
57
58
echo >&2 " non-executable tests:" $$ bad; exit 1; }
58
59
60
+ test-lint-shell-syntax :
61
+ @' $(PERL_PATH_SQ)' check-non-portable-shell.pl $(T )
62
+
59
63
aggregate-results-and-cleanup : $(T )
60
64
$(MAKE ) aggregate-results
61
65
$(MAKE ) clean
@@ -88,7 +92,7 @@ test-results:
88
92
mkdir -p test-results
89
93
90
94
test-results/git-smoke.tar.gz : test-results
91
- $( PERL_PATH ) ./harness \
95
+ ' $(PERL_PATH_SQ) ' ./harness \
92
96
--archive=" test-results/git-smoke.tar.gz" \
93
97
$(T )
94
98
Original file line number Diff line number Diff line change
1
+ # !/usr/bin/perl
2
+
3
+ # Test t0000..t9999.sh for non portable shell scripts
4
+ # This script can be called with one or more filenames as parameters
5
+
6
+ use strict;
7
+ use warnings;
8
+
9
+ my $exit_code =0;
10
+
11
+ sub err {
12
+ my $msg = shift ;
13
+ print " $ARGV :$. : error: $msg : $_ \n " ;
14
+ $exit_code = 1;
15
+ }
16
+
17
+ while (<>) {
18
+ chomp ;
19
+ / ^\s *sed\s +-i/ and err ' sed -i is not portable' ;
20
+ / ^\s *echo\s +-n/ and err ' echo -n is not portable (please use printf)' ;
21
+ / ^\s *declare\s +/ and err ' arrays/declare not portable' ;
22
+ / ^\s *[^#]\s *which\s / and err ' which is not portable (please use type)' ;
23
+ / test\s +[^=]*==/ and err ' "test a == b" is not portable (please use =)' ;
24
+ # this resets our $. for each file
25
+ close ARGV if eof ;
26
+ }
27
+ exit $exit_code ;
You can’t perform that action at this time.
0 commit comments