On Sat, Nov 08, 2008 at 03:56:18PM -0600, Raphael Geissert wrote: > Adam D. Barratt wrote: > > > On Sat, 2008-11-08 at 14:41 +0100, Filippo Giunchedi wrote: > >> Hi, > >> > >> On Sun, Nov 02, 2008 at 04:15:41PM +0000, Adam D. Barratt wrote: > >> > We are aware of the $'' bashism - indeed checkbashisms contains a > >> > commented-out check for it. The reason the check is disabled is that > >> > when it and a similar check for $"" were tested against the wide range > >> > of shell scripts available in Debian, they produced a high level of > >> > false positives and were disabled in devscripts 2.10.30, only one > >> > package after having been introduced. > >> > >> Are there any examples of such false positives? A list of packages is fine > >> :) > > Examples: > possible bashism in ./usr/sbin/afserverconfig line 173 ($'...' should be > "$(printf '...')"): > eval num_var_params='"$'values__$num_var_sp_idx'"' > > possible bashism in ./etc/cron.daily/changetrack line 22 ($'...' should be > "$(printf '...')"): > find /var/lib/dpkg/info -name '*.conffiles' -exec grep -v '.schemas$' > '{}' ';' | \
thanks! It seems like that the false positives are all generated by $ inside quotes, so it might be sufficient to check if preceding single quotes are odd or even. IOW here is a five minute hack: --- checkbashisms.pl (revision 1716) +++ checkbashisms.pl (working copy) @@ -307,6 +307,14 @@ output_explanation($filename, $orig_line, $explanation); } } + + my $re='(?<![\$\\\])\$\'[^\']+\''; + if ($line =~ m/(.*)($re)/){ + my $count = () = $1 =~ /(^|[^\\])\'/g; + if( $count % 2 == 0 ) { + output_explanation($filename, $orig_line, q<$'...' should be "$(printf '...')">); + } + } # $cat_line contains the version of the line we'll check # for heredoc delimiters later. Initially, remove any unless I'm missing something this might work for false positives, same goes for $" " of course filippo -- Filippo Giunchedi - http://esaurito.net PGP key: 0x6B79D401 random quote follows: Odium turbae sanabit solitudo, taedium solitudinis turba. Solitude will cure our hatred of the crowd, the crowd will cure our disgust with solitude. -- Seneca, De Tranquillitate Animi -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]