[SCM] Git repository for devscripts branch, jessie, updated. v2.12.4-100-gf153e56
James McCoy
jamessan at debian.org
Sun Nov 25 16:03:59 UTC 2012
The following commit has been merged in the jessie branch:
commit 54c363c363b37f008879996b8c179314792cea80
Author: Paul Wise <pabs at debian.org>
Date: Thu Nov 22 13:52:30 2012 +0800
Warn about bash scripts that do not have any bashisms
Signed-off-by: James McCoy <jamessan at debian.org>
diff --git a/debian/changelog b/debian/changelog
index 26b1f68..c48de51 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -12,6 +12,10 @@ devscripts (2.12.6+exp1) UNRELEASED; urgency=low
[ Dmitry Smirnov ]
* licensecheck: Remove any regular comments pattern. (Closes: #526698)
+ [ Paul Wise ]
+ * checkbashisms:
+ + When examining a bash script, indicate the lack of use of bashisms.
+
-- James McCoy <jamessan at debian.org> Sat, 15 Sep 2012 16:12:16 -0400
devscripts (2.12.6) unstable; urgency=low
diff --git a/scripts/checkbashisms.1 b/scripts/checkbashisms.1
index a835d3d..03d403e 100644
--- a/scripts/checkbashisms.1
+++ b/scripts/checkbashisms.1
@@ -57,6 +57,9 @@ A possible bashism was detected.
2
A file was skipped for some reason, for example, because it was
unreadable or not found. The warning message will give details.
+.TP
+4
+No bashisms were detected in a bash script.
.SH "SEE ALSO"
.BR lintian (1).
.SH AUTHOR
diff --git a/scripts/checkbashisms.pl b/scripts/checkbashisms.pl
index 6180d54..44f1f04 100755
--- a/scripts/checkbashisms.pl
+++ b/scripts/checkbashisms.pl
@@ -33,7 +33,7 @@ Usage: $progname [-n] [-f] [-x] script ...
or: $progname --help
or: $progname --version
This script performs basic checks for the presence of bashisms
-in /bin/sh scripts.
+in /bin/sh scripts and the lack of bashisms in /bin/bash ones.
EOF
my $version = <<"EOF";
@@ -74,6 +74,8 @@ if ($opt_version) { print $version; exit 0; }
$opt_echo = 1 if $opt_posix;
+my $mode = 0;
+my $issues = 0;
my $status = 0;
my $makefile = 0;
my (%bashisms, %string_bashisms, %singlequote_bashisms);
@@ -116,6 +118,8 @@ foreach my $filename (@ARGV) {
next;
}
+ $issues = 0;
+ $mode = 0;
my $cat_string = "";
my $cat_indented = 0;
my $quote_string = "";
@@ -143,9 +147,7 @@ foreach my $filename (@ARGV) {
next if $opt_force;
if ($interpreter =~ m,/bash$,) {
- warn "script $display_filename is already a bash script; skipping\n";
- $status |= 2;
- last; # end this file
+ $mode = 1;
}
elsif ($interpreter !~ m,/(sh|posh)$,) {
### ksh/zsh?
@@ -476,6 +478,11 @@ foreach my $filename (@ARGV) {
if ($buffered_line ne '');
close C;
+
+ if ($mode && !$issues) {
+ warn "could not find any possible bashisms in bash script $filename\n";
+ $status |= 4;
+ }
}
exit $status;
@@ -483,8 +490,14 @@ exit $status;
sub output_explanation {
my ($filename, $line, $explanation) = @_;
- warn "possible bashism in $filename line $. ($explanation):\n$line\n";
- $status |= 1;
+ if ($mode) {
+ # When examining a bash script, just flag that there are indeed
+ # bashisms present
+ $issues = 1;
+ } else {
+ warn "possible bashism in $filename line $. ($explanation):\n$line\n";
+ $status |= 1;
+ }
}
# Returns non-zero if the given file is not actually a shell script,
--
Git repository for devscripts
More information about the devscripts-devel
mailing list