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 7
7
use warnings;
8
8
9
9
my $exit_code =0;
10
+ my %func ;
10
11
11
12
sub err {
12
13
my $msg = shift ;
14
+ s / ^\s +// ;
15
+ s /\s +$// ;
16
+ s /\s +/ / g ;
13
17
print " $ARGV :$. : error: $msg : $_ \n " ;
14
18
$exit_code = 1;
15
19
}
16
20
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
+
17
30
while (<>) {
18
31
chomp ;
32
+ # stitch together incomplete lines (those ending with "\")
33
+ while (s /\\ $// ) {
34
+ $_ .= readline;
35
+ chomp ;
36
+ }
37
+
19
38
/ \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)' ;
21
40
/ ^\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"' ;
26
47
# this resets our $. for each file
27
48
close ARGV if eof ;
28
49
}
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' '
366
366
367
367
git checkout A^0 &&
368
368
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 &&
370
372
371
373
test_i18ngrep "CONFLICT (rename/add): Rename b->c" out &&
372
374
test_i18ngrep ! "Skipped c" out &&
Original file line number Diff line number Diff line change @@ -26,7 +26,9 @@ test_expect_success 'error handling' '
26
26
) &&
27
27
p4 passwd -P newpassword &&
28
28
(
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 &&
30
32
grep -q "failure accessing depot.*P4PASSWD" errmsg
31
33
)
32
34
'
You can’t perform that action at this time.
0 commit comments