]>
Commit | Line | Data |
---|---|---|
c7ce70ac TB |
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; | |
c4336005 ES |
13 | s/^\s+//; |
14 | s/\s+$//; | |
c7ce70ac TB |
15 | print "$ARGV:$.: error: $msg: $_\n"; |
16 | $exit_code = 1; | |
17 | } | |
18 | ||
19 | while (<>) { | |
20 | chomp; | |
561b46c5 | 21 | /\bsed\s+-i/ and err 'sed -i is not portable'; |
ef2d2acc | 22 | /\becho\s+-[neE]/ and err 'echo with option is not portable (use printf)'; |
c7ce70ac | 23 | /^\s*declare\s+/ and err 'arrays/declare not portable'; |
ef2d2acc ES |
24 | /^\s*[^#]\s*which\s/ and err 'which is not portable (use type)'; |
25 | /\btest\s+[^=]*==/ and err '"test a == b" is not portable (use =)'; | |
26 | /\bwc -l.*"\s*=/ and err '`"$(wc -l)"` is not portable (use test_line_count)'; | |
27 | /\bexport\s+[A-Za-z0-9_]*=/ and err '"export FOO=bar" is not portable (use FOO=bar && export FOO)'; | |
c7ce70ac TB |
28 | # this resets our $. for each file |
29 | close ARGV if eof; | |
30 | } | |
31 | exit $exit_code; |