| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: check-portability.awk,v 1.7 2014/03/11 23:23:01 ryoon Exp $ | | 1 | # $NetBSD: check-portability.awk,v 1.8 2014/03/11 23:27:40 ryoon Exp $ |
2 | # | | 2 | # |
3 | # Checks a shell file for possible portability problems. | | 3 | # Checks a shell file for possible portability problems. |
4 | # | | 4 | # |
5 | # ENVIRONMENT | | 5 | # ENVIRONMENT |
6 | # (See check-subr.awk) | | 6 | # (See check-subr.awk) |
7 | # | | 7 | # |
8 | | | 8 | |
9 | BEGIN { | | 9 | BEGIN { |
10 | found_random = no; | | 10 | found_random = no; |
11 | found_test_eqeq = no; | | 11 | found_test_eqeq = no; |
12 | } | | 12 | } |
13 | | | 13 | |
14 | # Check for $RANDOM, which is specific to ksh and bash. | | 14 | # Check for $RANDOM, which is specific to ksh and bash. |
| @@ -21,28 +21,26 @@ function check_random(line) { | | | @@ -21,28 +21,26 @@ function check_random(line) { |
21 | | | 21 | |
22 | } else if (line ~ /\$RANDOM[A-Z_]+/) { | | 22 | } else if (line ~ /\$RANDOM[A-Z_]+/) { |
23 | # That's ok, too. | | 23 | # That's ok, too. |
24 | | | 24 | |
25 | } else if (line ~ /\$RANDOM/) { | | 25 | } else if (line ~ /\$RANDOM/) { |
26 | found_random = yes; | | 26 | found_random = yes; |
27 | cs_warning_heading("Found $RANDOM:"); | | 27 | cs_warning_heading("Found $RANDOM:"); |
28 | cs_warning_msg(cs_fname ": " $0); | | 28 | cs_warning_msg(cs_fname ": " $0); |
29 | } | | 29 | } |
30 | } | | 30 | } |
31 | | | 31 | |
32 | function check_test_eqeq(line, n, word, i) { | | 32 | function check_test_eqeq(line, n, word, i) { |
33 | | | 33 | |
34 | if (length(line) ==0 || length(word) == 0) | | | |
35 | return; | | | |
36 | n = split(line, word); | | 34 | n = split(line, word); |
37 | for (i = 3; i < n; i++) { | | 35 | for (i = 3; i < n; i++) { |
38 | if (word[i] == "==") { | | 36 | if (word[i] == "==") { |
39 | if (word[i-2] == "test" || word[i-2] == "[") { | | 37 | if (word[i-2] == "test" || word[i-2] == "[") { |
40 | found_test_eqeq = yes; | | 38 | found_test_eqeq = yes; |
41 | cs_error_heading("Found test ... == ...:"); | | 39 | cs_error_heading("Found test ... == ...:"); |
42 | cs_error_msg(cs_fname ": " $0); | | 40 | cs_error_msg(cs_fname ": " $0); |
43 | } | | 41 | } |
44 | } | | 42 | } |
45 | } | | 43 | } |
46 | } | | 44 | } |
47 | | | 45 | |
48 | /./ { | | 46 | /./ { |