Author: adam-guest
Date: 2008-06-02 18:45:23 +0000 (Mon, 02 Jun 2008)
New Revision: 1472
Modified:
trunk/debian/changelog
trunk/scripts/checkbashisms.pl
Log:
Add checks for $'', $"", the use of echo with backslash escapes, $SHLVL,
$POSIXLY_CORRECT and $PIPESTATUS. Based on a patch by Raphael Geissert.
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2008-06-01 00:10:15 UTC (rev 1471)
+++ trunk/debian/changelog 2008-06-02 18:45:23 UTC (rev 1472)
@@ -5,6 +5,8 @@
+ Don't treat scripts with dash or ash shebangs as "/bin/sh scripts", as
dash implements some extensions to POSIX
+ Correctly match heredocs using "<<-"
+ + Add checks for $'', $"", the use of echo with backslash escapes, $SHLVL,
+ $POSIXLY_CORRECT and $PIPESTATUS. Based on a patch by Raphael Geissert.
* debchange: Update the manual page to refer to +nmu versioning for native
packages (Closes: #483861)
* debdiff: Don't apply patches when extracting a Format 3.0 (quilt) source
Modified: trunk/scripts/checkbashisms.pl
===================================================================
--- trunk/scripts/checkbashisms.pl 2008-06-01 00:10:15 UTC (rev 1471)
+++ trunk/scripts/checkbashisms.pl 2008-06-02 18:45:23 UTC (rev 1472)
@@ -69,7 +69,7 @@
my $status = 0;
my $makefile = 0;
-my (%bashisms, %string_bashisms);
+my (%bashisms, %string_bashisms, %singlequote_bashisms);
init_hashes;
@@ -280,6 +280,15 @@
$line =~ s/(^|[^\\\'\"])\"\'\"/$1/g;
$line =~ s/(^|[^\\\'\"])\'\"\'/$1/g;
+ while (my ($re,$expl) = each %singlequote_bashisms) {
+ if ($line =~ m/($re)/) {
+ $found = 1;
+ $match = $1;
+ $explanation = $expl;
+ output_explanation($filename, $orig_line, $explanation);
+ }
+ }
+
# $cat_line contains the version of the line we'll check
# for heredoc delimeters later. Initially, remove any
# spaces between << and the delimeter to make the following
@@ -420,9 +429,9 @@
$LEADIN . 'dirs\b' => q<dirs>,
'(?:^|\s+)[<>]\(.*?\)' => q<\<() process substituion>,
'(?:^|\s+)readonly\s+-[af]' => q<readonly -[af]>,
- $LEADIN . 'sh -[rD]' => q<sh -[rD]>,
- $LEADIN . 'sh --\w+' => q<sh --long-option>,
- $LEADIN . 'sh [-+]O' => q<sh [-+]O>,
+ $LEADIN . '(sh|\$\{?SHELL\}?) -[rD]' => q<sh -[rD]>,
+ $LEADIN . '(sh|\$\{?SHELL\}?) --\w+' => q<sh --long-option>,
+ $LEADIN . '(sh|\$\{?SHELL\}?) [-+]O' => q<sh [-+]O>,
);
%string_bashisms = (
@@ -441,9 +450,18 @@
'\$\{?SECONDS\}?\b' => q<$SECONDS>,
'\$\{?BASH_[A-Z]+\}?\b' => q<$BASH_SOMETHING>,
'\$\{?SHELLOPTS\}?\b' => q<$SHELLOPTS>,
+ '\$\{?PIPESTATUS\}?\b' => q<$PIPESTATUS>,
+ '\$\{?SHLVL\}?\b' => q<$SHLVL>,
'<<<' => q<\<\<\< here string>,
+ $LEADIN .
'echo\s+(?:-[^e]+\s+)?([\"])[^\"]*(\\\[abcEfnrtv\\\0])+.*?[\"]' => q<unsafe
echo with backslash>,
+ '(?<![\$\\\])\$\"[^\"]+\"' => q<$"foo" should be eval gettext "foo">,
);
+ %singlequote_bashisms = (
+ $LEADIN .
'echo\s+(?:-[^e]+\s+)?([\'])[^\']*(\\\[abcEfnrtv\\\0])+.*?[\']' => q<unsafe
echo with backslash>,
+ '(?<![\$\\\])\$\'[^\']+\'' => q<$'...' should be "$(printf
'...')">,
+ );
+
if ($opt_echo) {
$bashisms{'echo\s+-[n]'} = q<echo -n>;
}
@@ -465,5 +483,6 @@
$string_bashisms{'(?:^|\s+)EUID='} = q<EUID=>;
$string_bashisms{'(?:^|\s+)BASH(_[A-Z]+)?='} = q<BASH(_SOMETHING)=>;
$string_bashisms{'(?:^|\s+)SHELLOPTS='} = q<SHELLOPTS=>;
+ $string_bashisms{'\$\{?POSIXLY_CORRECT\}?\b'} = q<$POSIXLY_CORRECT>;
}
}
--
To unsubscribe, send mail to [EMAIL PROTECTED]