File tree Expand file tree Collapse file tree 3 files changed +32
-7
lines changed
Expand file tree Collapse file tree 3 files changed +32
-7
lines changed Original file line number Diff line number Diff line change 77use warnings;
88
99my $exit_code =0;
10+ my %func ;
1011
1112sub err {
1213 my $msg = shift ;
14+ s / ^\s +// ;
15+ s /\s +$// ;
16+ s /\s +/ / g ;
1317 print " $ARGV :$. : error: $msg : $_ \n " ;
1418 $exit_code = 1;
1519}
1620
21+ # glean names of shell functions
22+ for my $i (@ARGV ) {
23+ open (my $f , ' <' , $i ) or die " $0 : $i : $! \n " ;
24+ while (<$f >) {
25+ $func {$1 } = 1 if / ^\s *(\w +)\s *\(\)\s *{\s *$ / ;
26+ }
27+ close $f ;
28+ }
29+
1730while (<>) {
1831 chomp ;
32+ # stitch together incomplete lines (those ending with "\")
33+ while (s /\\ $// ) {
34+ $_ .= readline;
35+ chomp ;
36+ }
37+
1938 / \b sed\s +-i/ and err ' sed -i is not portable' ;
20- / \b echo\s +-[neE]/ and err ' echo with option is not portable (please use printf)' ;
39+ / \b echo\s +-[neE]/ and err ' echo with option is not portable (use printf)' ;
2140 / ^\s *declare\s +/ and err ' arrays/declare not portable' ;
22- / ^\s *[^#]\s *which\s / and err ' which is not portable (please use type)' ;
23- / \b test\s +[^=]*==/ and err ' "test a == b" is not portable (please use =)' ;
24- / \b wc -l.*"\s *=/ and err ' `"$(wc -l)"` is not portable (please use test_line_count)' ;
25- / \b export\s +[A-Za-z0-9_]*=/ and err ' "export FOO=bar" is not portable (please use FOO=bar && export FOO)' ;
41+ / ^\s *[^#]\s *which\s / and err ' which is not portable (use type)' ;
42+ / \b test\s +[^=]*==/ and err ' "test a == b" is not portable (use =)' ;
43+ / \b wc -l.*"\s *=/ and err ' `"$(wc -l)"` is not portable (use test_line_count)' ;
44+ / \b export\s +[A-Za-z0-9_]*=/ and err ' "export FOO=bar" is not portable (use FOO=bar && export FOO)' ;
45+ / ^\s *([A-Z0-9_]+=(\w +|(["']).*?\3 )\s +)+(\w +)/ and exists ($func {$4 }) and
46+ err ' "FOO=bar shell_func" assignment extends beyond "shell_func"' ;
2647 # this resets our $. for each file
2748 close ARGV if eof ;
2849}
Original file line number Diff line number Diff line change @@ -366,7 +366,9 @@ test_expect_success '2c-check: Modify b & add c VS rename b->c' '
366366
367367 git checkout A^0 &&
368368
369- GIT_MERGE_VERBOSITY=3 test_must_fail git merge -s recursive B^0 >out 2>err &&
369+ GIT_MERGE_VERBOSITY=3 &&
370+ export GIT_MERGE_VERBOSITY &&
371+ test_must_fail git merge -s recursive B^0 >out 2>err &&
370372
371373 test_i18ngrep "CONFLICT (rename/add): Rename b->c" out &&
372374 test_i18ngrep ! "Skipped c" out &&
Original file line number Diff line number Diff line change @@ -26,7 +26,9 @@ test_expect_success 'error handling' '
2626 ) &&
2727 p4 passwd -P newpassword &&
2828 (
29- P4PASSWD=badpassword test_must_fail git p4 clone //depot/foo 2>errmsg &&
29+ P4PASSWD=badpassword &&
30+ export P4PASSWD &&
31+ test_must_fail git p4 clone //depot/foo 2>errmsg &&
3032 grep -q "failure accessing depot.*P4PASSWD" errmsg
3133 )
3234'
You can’t perform that action at this time.
0 commit comments