tag 469023 patch
thanks

Attaching proposed patch.
Note that I've moved the portion of code processing the options so -n and -f 
can be used at the same time.

Cheers,
-- 
Atomo64 - Raphael

Please avoid sending me Word, PowerPoint or Excel attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
--- /home/raphael/bin/local/checkbashisms	2008-03-02 12:45:18.000000000 -0600
+++ ./checkbashisms	2008-03-02 13:22:15.000000000 -0600
@@ -28,7 +28,7 @@
 (my $progname = $0) =~ s|.*/||;
 
 my $usage = <<"EOF";
-Usage: $progname [-n] script ...
+Usage: $progname [-n|-f] script ...
    or: $progname --help
    or: $progname --version
 This script performs basic checks for the presence of bashisms
@@ -45,22 +45,25 @@
 GNU General Public License, version 2, or (at your option) any later version.
 EOF
 
-my $opt_echo = 0;
+my ($opt_echo, $opt_force) = (0, 0);
 
 ##
 ## handle command-line options
 ##
 if (int(@ARGV) == 0 or $ARGV[0] =~ /^(--help|-h)$/) { print $usage; exit 0; }
 if (@ARGV and $ARGV[0] =~ /^(--version|-v)$/) { print $version; exit 0; }
-if (@ARGV and $ARGV[0] =~ /^(--newline|-n)$/) { $opt_echo = 1; }
 
 
 my $status = 0;
 
 foreach my $filename (@ARGV) {
     if ($filename eq '-n' or $filename eq '--newline') {
+	$opt_echo = 1;
 	next;
-    } elsif (script_is_evil_and_wrong($filename)) {
+    } elsif ($filename eq '-f' or $filename eq '--force') {
+	$opt_force = 1;
+	next;
+    } elsif (!$opt_force and script_is_evil_and_wrong($filename)) {
 	warn "script $filename does not appear to be a /bin/sh script; skipping\n";
 	next;
     }
@@ -76,12 +79,12 @@
 	if ($. == 1) { # This should be an interpreter line
 	    if (m,^\#!\s*(\S+),) {
 		my $interpreter = $1;
-		if ($interpreter =~ m,/bash$,) {
+		if (!$opt_force and $interpreter =~ m,/bash$,) {
 		    warn "script $filename is already a bash script; skipping\n";
 		    $status |= 2;
 		    last;  # end this file
 		}
-		elsif ($interpreter !~ m,/(sh|ash|dash|posh)$,) {
+		elsif (!$opt_force and $interpreter !~ m,/(sh|ash|dash|posh)$,) {
 ### ksh/zsh?
 		    warn "script $filename does not appear to be a /bin/sh script; skipping\n";
 		    $status |= 2;

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to