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 6use strict; 7use warnings; 8 9my$exit_code=0; 10 11sub err { 12my$msg=shift; 13s/^\s+//; 14s/\s+$//; 15print"$ARGV:$.: error:$msg:$_\n"; 16$exit_code=1; 17} 18 19while(<>) { 20chomp; 21/\bsed\s+-i/and err 'sed -i is not portable'; 22/\becho\s+-[neE]/and err 'echo with option is not portable (use printf)'; 23/^\s*declare\s+/and err 'arrays/declare not portable'; 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)'; 28# this resets our $. for each file 29close ARGV ifeof; 30} 31exit$exit_code;