Author: adsb
Date: 2009-05-28 19:54:16 +0000 (Thu, 28 May 2009)
New Revision: 1890
Modified:
trunk/debian/changelog
trunk/scripts/checkbashisms.pl
Log:
* checkbashisms:
+ Detect shellscript wrappers that use "then" or "else" before calling
exec. Thanks, Raphael Geissert. (Closes: #530815)
+ Fix a false positive detection of ". $(foo bar)" as attempting to pass
arguments to a sourced script. Thanks, Raphael Geissert.
+ Detect use of passing arguments to a sourced script as part of a
conditional statement. Thanks, Raphael Geissert.
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2009-05-25 21:43:09 UTC (rev 1889)
+++ trunk/debian/changelog 2009-05-28 19:54:16 UTC (rev 1890)
@@ -1,6 +1,13 @@
devscripts (2.10.51) UNRELEASED; urgency=low
[ Adam D. Barratt ]
+ * checkbashisms:
+ + Detect shellscript wrappers that use "then" or "else" before calling
+ exec. Thanks, Raphael Geissert. (Closes: #530815)
+ + Fix a false positive detection of ". $(foo bar)" as attempting to pass
+ arguments to a sourced script. Thanks, Raphael Geissert.
+ + Detect use of passing arguments to a sourced script as part of a
+ conditional statement. Thanks, Raphael Geissert.
* uscan: Make a regular expression example in the manpage clearer. Thanks,
Jason Heeris. (Closes: #530362)
Modified: trunk/scripts/checkbashisms.pl
===================================================================
--- trunk/scripts/checkbashisms.pl 2009-05-25 21:43:09 UTC (rev 1889)
+++ trunk/scripts/checkbashisms.pl 2009-05-28 19:54:16 UTC (rev 1890)
@@ -74,6 +74,7 @@
my $makefile = 0;
my (%bashisms, %string_bashisms, %singlequote_bashisms);
+my $LEADIN = qr'(?:(?:^|[`&;(|{])\s*|(?:if|then|do|while|shell)\s+)';
init_hashes;
foreach my $filename (@ARGV) {
@@ -281,8 +282,8 @@
# detect source (.) trying to pass args to the command it runs
# The first expression weeds out '. "foo bar"'
if (not $found and
- not m/^\s*\.\s+(\"[^\"]+\"|\'[^\']+\')\s*(\&|\||\d?>|<|;|\Z)/
- and m/^\s*(\.\s+[^\s;\`:]+\s+([^\s;]+))/) {
+ not
m/$LEADIN\.\s+(\"[^\"]+\"|\'[^\']+\'|\$\([^)]+\)+)\s*(\&|\||\d?>|<|;|\Z)/
+ and m/$LEADIN(\.\s+[^\s;\`:]+\s+([^\s;]+))/) {
if ($2 =~ /^(\&|\||\d?>|<)/) {
# everything is ok
;
@@ -408,7 +409,7 @@
last if (++$i > 55);
if (m~
# the exec should either be "eval"ed or a new statement
- (^\s*|\beval\s*[\'\"]|(;|&&)\s*)
+ (^\s*|\beval\s*[\'\"]|(;|&&|\b(then|else))\s*)
# eat anything between the exec and $0
exec\s*.+\s*
@@ -445,7 +446,7 @@
$backgrounded = 1;
} elsif ($backgrounded and m~
# the exec should either be "eval"ed or a new statement
- (^\s*|\beval\s*[\'\"]|(;|&&)\s*)
+ (^\s*|\beval\s*[\'\"]|(;|&&|\b(then|else))\s*)
exec\s+true(\s|\Z)~x) {
$ret = $. - 1;
@@ -458,7 +459,6 @@
}
sub init_hashes {
- my $LEADIN = qr'(?:(^|[`&;(|{])\s*|(if|then|do|while|shell)\s+)';
%bashisms = (
qr'(?:^|\s+)function \w+(\s|\(|\Z)' => q<'function' is useless>,
--
To unsubscribe, send mail to [email protected].