| @@ -1,15 +1,15 @@ | | | @@ -1,15 +1,15 @@ |
1 | #! @PERL@ | | 1 | #! @PERL@ |
2 | # $NetBSD: pkglint.pl,v 1.761 2008/01/31 13:20:56 rillig Exp $ | | 2 | # $NetBSD: pkglint.pl,v 1.762 2008/01/31 14:00:17 rillig Exp $ |
3 | # | | 3 | # |
4 | | | 4 | |
5 | # pkglint - static analyzer and checker for pkgsrc packages | | 5 | # pkglint - static analyzer and checker for pkgsrc packages |
6 | # | | 6 | # |
7 | # Written by: | | 7 | # Written by: |
8 | # Roland Illig <rillig@NetBSD.org> | | 8 | # Roland Illig <rillig@NetBSD.org> |
9 | # | | 9 | # |
10 | # Based on work by: | | 10 | # Based on work by: |
11 | # Hubert Feyrer <hubertf@NetBSD.org> | | 11 | # Hubert Feyrer <hubertf@NetBSD.org> |
12 | # Thorsten Frueauf <frueauf@NetBSD.org> | | 12 | # Thorsten Frueauf <frueauf@NetBSD.org> |
13 | # Thomas Klausner <wiz@NetBSD.org> | | 13 | # Thomas Klausner <wiz@NetBSD.org> |
14 | # and others. | | 14 | # and others. |
15 | # | | 15 | # |
| @@ -4595,58 +4595,63 @@ sub checkline_mk_shelltext($$) { | | | @@ -4595,58 +4595,63 @@ sub checkline_mk_shelltext($$) { |
4595 | $vartools = get_vartool_names(); | | 4595 | $vartools = get_vartool_names(); |
4596 | $rest = $text; | | 4596 | $rest = $text; |
4597 | | | 4597 | |
4598 | use constant hidden_shell_commands => array_to_hash(qw( | | 4598 | use constant hidden_shell_commands => array_to_hash(qw( |
4599 | ${DELAYED_ERROR_MSG} ${DELAYED_WARNING_MSG} | | 4599 | ${DELAYED_ERROR_MSG} ${DELAYED_WARNING_MSG} |
4600 | ${DO_NADA} | | 4600 | ${DO_NADA} |
4601 | ${ECHO} ${ECHO_MSG} ${ECHO_N} ${ERROR_CAT} ${ERROR_MSG} | | 4601 | ${ECHO} ${ECHO_MSG} ${ECHO_N} ${ERROR_CAT} ${ERROR_MSG} |
4602 | ${FAIL_MSG} | | 4602 | ${FAIL_MSG} |
4603 | ${PHASE_MSG} ${PRINTF} | | 4603 | ${PHASE_MSG} ${PRINTF} |
4604 | ${SHCOMMENT} ${STEP_MSG} | | 4604 | ${SHCOMMENT} ${STEP_MSG} |
4605 | ${WARNING_CAT} ${WARNING_MSG} | | 4605 | ${WARNING_CAT} ${WARNING_MSG} |
4606 | )); | | 4606 | )); |
4607 | | | 4607 | |
4608 | if ($rest =~ s/^\s*([-@]*)(?:\$\{_PKG_SILENT\}\$\{_PKG_DEBUG\})?//) { | | 4608 | $set_e_mode = false; |
4609 | my ($hidden) = ($1); | | 4609 | |
| | | 4610 | if ($rest =~ s/^\s*([-@]*)(\$\{_PKG_SILENT\}\$\{_PKG_DEBUG\}|\${RUN}|)//) { |
| | | 4611 | my ($hidden, $macro) = ($1, $2); |
4610 | | | 4612 | |
4611 | if ($hidden !~ qr"\@") { | | 4613 | if ($hidden !~ qr"\@") { |
4612 | # Nothing is hidden at all. | | 4614 | # Nothing is hidden at all. |
4613 | | | 4615 | |
4614 | } elsif (defined($mkctx_target) && $mkctx_target =~ qr"^(?:show-.*|.*-message)$") { | | 4616 | } elsif (defined($mkctx_target) && $mkctx_target =~ qr"^(?:show-.*|.*-message)$") { |
4615 | # In some targets commands may be hidden. | | 4617 | # In some targets commands may be hidden. |
4616 | | | 4618 | |
4617 | } elsif ($rest =~ $regex_shellword) { | | 4619 | } elsif ($rest =~ $regex_shellword) { |
4618 | my ($cmd) = ($1); | | 4620 | my ($cmd) = ($1); |
4619 | | | 4621 | |
4620 | if (!exists(hidden_shell_commands->{$cmd})) { | | 4622 | if (!exists(hidden_shell_commands->{$cmd})) { |
4621 | $line->log_warning("The shell command \"${cmd}\" should not be hidden."); | | 4623 | $line->log_warning("The shell command \"${cmd}\" should not be hidden."); |
4622 | $line->explain_warning( | | 4624 | $line->explain_warning( |
4623 | "Hidden shell commands do not appear on the terminal or in the log file", | | 4625 | "Hidden shell commands do not appear on the terminal or in the log file", |
4624 | "when they are executed. When they fail, the error message cannot be", | | 4626 | "when they are executed. When they fail, the error message cannot be", |
4625 | "assigned to the command, which is very difficult to debug."); | | 4627 | "assigned to the command, which is very difficult to debug."); |
4626 | } | | 4628 | } |
4627 | } | | 4629 | } |
4628 | | | 4630 | |
4629 | if ($hidden =~ qr"-") { | | 4631 | if ($hidden =~ qr"-") { |
4630 | $line->log_warning("The use of a leading \"-\" to suppress errors is deprecated."); | | 4632 | $line->log_warning("The use of a leading \"-\" to suppress errors is deprecated."); |
4631 | $line->explain_warning( | | 4633 | $line->explain_warning( |
4632 | "If you really want to ignore any errors from this command (including", | | 4634 | "If you really want to ignore any errors from this command (including", |
4633 | "all errors you never thought of), append \"|| \${TRUE}\" to the", | | 4635 | "all errors you never thought of), append \"|| \${TRUE}\" to the", |
4634 | "command."); | | 4636 | "command."); |
4635 | } | | 4637 | } |
| | | 4638 | |
| | | 4639 | if ($macro eq "\${RUN}") { |
| | | 4640 | $set_e_mode = true; |
| | | 4641 | } |
4636 | } | | 4642 | } |
4637 | | | 4643 | |
4638 | $state = SCST_START; | | 4644 | $state = SCST_START; |
4639 | $set_e_mode = false; | | | |
4640 | while ($rest =~ s/^$regex_shellword//) { | | 4645 | while ($rest =~ s/^$regex_shellword//) { |
4641 | my ($shellword) = ($1); | | 4646 | my ($shellword) = ($1); |
4642 | | | 4647 | |
4643 | $opt_debug_shell and $line->log_debug(scst_statename->[$state] . ": ${shellword}"); | | 4648 | $opt_debug_shell and $line->log_debug(scst_statename->[$state] . ": ${shellword}"); |
4644 | | | 4649 | |
4645 | checkline_mk_shellword($line, $shellword, !( | | 4650 | checkline_mk_shellword($line, $shellword, !( |
4646 | $state == SCST_CASE | | 4651 | $state == SCST_CASE |
4647 | || $state == SCST_FOR_CONT | | 4652 | || $state == SCST_FOR_CONT |
4648 | || $state == SCST_SET_CONT | | 4653 | || $state == SCST_SET_CONT |
4649 | || ($state == SCST_START && $shellword =~ regex_sh_varassign))); | | 4654 | || ($state == SCST_START && $shellword =~ regex_sh_varassign))); |
4650 | | | 4655 | |
4651 | # | | 4656 | # |
4652 | # Actions associated with the current state | | 4657 | # Actions associated with the current state |