Author: adam-guest
Date: 2008-03-15 15:40:30 +0000 (Sat, 15 Mar 2008)
New Revision: 1136

Modified:
   trunk/debian/changelog
   trunk/scripts/checkbashisms.1
   trunk/scripts/checkbashisms.pl
Log:
  + Add an option to allow flagging of lines which do not contain bashisms
    but which may contain other useful information - for example, checking
    whether $BASH is set before using bashisms or $RANDOM being used as a
    local variable rather than the bash built-in variable (Closes: #470999)

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog      2008-03-15 15:20:21 UTC (rev 1135)
+++ trunk/debian/changelog      2008-03-15 15:40:30 UTC (rev 1136)
@@ -36,6 +36,10 @@
       alphanumerics and underscore
     + Modify the "read without variable" test to also catch options other
       than -r. Thanks Luca Capello (Closes: #470696)
+    + Add an option to allow flagging of lines which do not contain bashisms
+      but which may contain other useful information - for example, checking
+      whether $BASH is set before using bashisms or $RANDOM being used as a
+      local variable rather than the bash built-in variable (Closes: #470999)
   * bts:
     + Allow the sendmail command to begin with a ~ (Closes: #469207)
     + Don't treat "userblah" as an alias for "users" in "select"

Modified: trunk/scripts/checkbashisms.1
===================================================================
--- trunk/scripts/checkbashisms.1       2008-03-15 15:20:21 UTC (rev 1135)
+++ trunk/scripts/checkbashisms.1       2008-03-15 15:40:30 UTC (rev 1136)
@@ -33,6 +33,13 @@
 instance, it has a bash or non POSIX shell shebang or appears to be a 
 shell wrapper).
 .TP
+.BR \-\-extra ", " \-x
+Highlight lines which, whilst they do not contain bashisms, may be
+useful in determining whether a particular issue is a false positive
+which may be ignored.
+For example, the use of "$BASH_ENV" may be preceeded by checking
+whether "$BASH" is set.
+.TP
 .BR \-\-version ", " \-v
 Show version and copyright information.
 .SH "EXIT VALUES"

Modified: trunk/scripts/checkbashisms.pl
===================================================================
--- trunk/scripts/checkbashisms.pl      2008-03-15 15:20:21 UTC (rev 1135)
+++ trunk/scripts/checkbashisms.pl      2008-03-15 15:40:30 UTC (rev 1136)
@@ -46,7 +46,7 @@
 GNU General Public License, version 2, or (at your option) any later version.
 EOF
 
-my ($opt_echo, $opt_force);
+my ($opt_echo, $opt_force, $opt_extra);
 my ($opt_help, $opt_version);
 
 ##
@@ -56,6 +56,7 @@
           "version|v" => \$opt_version,
           "newline|n" => \$opt_echo,
           "force|f" => \$opt_force,
+          "extra|x" => \$opt_extra,
            )
     or die "Usage: $progname [options] filelist\nRun $progname --help for more 
details\n";
 
@@ -186,13 +187,23 @@
                '\$\{?DIRSTACK\}?\b'        => q<$DIRSTACK>,
                '\$\{?EUID\}?\b'            => q<$EUID should be "id -u">,
                '\$\{?SECONDS\}?\b'         => q<$SECONDS>,
-               '\$\{?BASH(_[A-Z]+)?\}?\b'   => q<$BASH(_SOMETHING)>,
+               '\$\{?BASH_[A-Z]+\}?\b'     => q<$BASH_SOMETHING>,
            );
 
            if ($opt_echo) {
                $bashisms{'echo\s+-[n]'} = 'q<echo -n>';
            }
 
+           if ($opt_extra) {
+               $string_bashisms{'\$\{?BASH\}?\b'} = 'q<$BASH>';
+               $string_bashisms{'(?:^|\s+)RANDOM='} = 'q<RANDOM=>';
+               $string_bashisms{'(?:^|\s+)(OS|MACH)TYPE='} = 
'q<(OS|MACH)TYPE=>';
+               $string_bashisms{'(?:^|\s+)HOST(TYPE|NAME)='} = 
'q<HOST(TYPE|NAME)=>';
+               $string_bashisms{'(?:^|\s+)DIRSTACK='} = 'q<DIRSTACK=>';
+               $string_bashisms{'(?:^|\s+)EUID='} = 'q<EUID=>';
+               $string_bashisms{'(?:^|\s+)BASH(_[A-Z]+)?='} = 
'q<BASH(_SOMETHING)=>';
+           }
+
            my $line = $_;
 
            if ($quote_string ne "") {



-- 
To unsubscribe, send mail to [EMAIL PROTECTED]

Reply via email to