Yet another patch + how to check for stuff in shell scripts
Hi all,
Last time I filed bug reports for the dash RG thanks to the package
maintainers I noticed that there's a 'time' package which provides the same
functionality of bash's 'time' built-in.
So here's a patch which avoids emitting the bashisms tag if the match
is 'time' and there's a dependency on the 'time' package.
Additionally I've improved the regex used to emit the
maintainer-script-hides-init-failure tag.
Besides that patch, I'd like to know the opinion of others about how shell
scripts should be checked. At the moment checks/scripts now makes use of
$LEADIN as a separator/command identifier, but other checks also checking
for stuff in shell script don't.
This caused me troubles when I prefixed the invoke-rc.d calls in
testset/scripts/debian/postinst with 'time'. Doing that caused most, if not
all, of checks/init.d results to be completely incorrect because it failed
to detect the invoke-rc.d calls.
Although that problem could not be avoided just by using $LEADIN
(because 'time' is not in the list of separators, so someone please add it)
similar problems can.
Cheers,
--
Atomo64 - Raphael
Please avoid sending me Word, PowerPoint or Excel attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
diff --git a/checks/scripts b/checks/scripts
index c73ceaf..3e3b0c0 100644
--- a/checks/scripts
+++ b/checks/scripts
@@ -697,9 +697,12 @@ while (<SCRIPTS>) {
$line =~ s/(^|[^\\\'](?:\\\\)*)\"(?:\\.|[^\\\"])+\"/$1""/g;
for my $re (@bashism_regexs) {
if ($line =~ m/($re)/) {
- $found = 1;
($match) = m/($re)/;
- last;
+ unless ($match =~ m/^\s*time\s*$/ &&
+ Dep::implies($deps{depends}, Dep::parse('time'))) {
+ $found = 1;
+ last;
+ }
}
}
}
@@ -723,7 +726,7 @@ while (<SCRIPTS>) {
if (/(chown(\s+--?[A-Za-z-]+)*\s+[-_A-Za-z0-9]+\.[-_A-Za-z0-9]+)\s+/) {
tag "deprecated-chown-usage", "$file:$. \'$1\'";
}
- if (/invoke-rc.d.*\|\| exit 0/) {
+ if (/invoke-rc\.d.*\|\|\s*exit\s+0/) {
tag "maintainer-script-hides-init-failure", "$file:$.";
}
if (m,/usr/share/debconf/confmodule,) {
diff --git a/testset/scripts/debian/control b/testset/scripts/debian/control
index 3a290fa..5bb8ccc 100644
--- a/testset/scripts/debian/control
+++ b/testset/scripts/debian/control
@@ -8,7 +8,7 @@ Standards-Version: 3.2.1
Package: scripts
Architecture: all
-Depends: test, ruby1.8, build-essential, libssl0.9.7
+Depends: test, ruby1.8, build-essential, libssl0.9.7, time
Recommends: tk8.4 | wish
Description: test lintian's script file checks
Regression test lintian's script file checks.
diff --git a/testset/scripts/debian/postinst b/testset/scripts/debian/postinst
index 4172b09..212e3f9 100644
--- a/testset/scripts/debian/postinst
+++ b/testset/scripts/debian/postinst
@@ -12,3 +12,5 @@ fi
if [ -x "/etc/init.d/lsb-other" ] ; then
update-rc.d lsb-other defaults >/dev/null
fi
+
+time foo
Reply to: