Author: adam-guest
Date: 2008-03-02 21:24:16 +0000 (Sun, 02 Mar 2008)
New Revision: 1091

Modified:
   trunk/debian/changelog
   trunk/scripts/checkbashisms.pl
Log:
checkbashisms:
  + Use Getopt::Long for option parsing

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog      2008-03-01 11:59:04 UTC (rev 1090)
+++ trunk/debian/changelog      2008-03-02 21:24:16 UTC (rev 1091)
@@ -4,6 +4,8 @@
     file if none was passed on the command line (Closes: #468761)
   * debchange: Apply a more elegant fix for the bugfix in 2.10.18.
     Thanks to gregor herrmann for pointing the obvious solution out.
+  * checkbashisms:
+    + Use Getopt::Long for option parsing
 
  -- Adam D. Barratt <[EMAIL PROTECTED]>  Sat, 01 Mar 2008 11:42:02 +0000
 

Modified: trunk/scripts/checkbashisms.pl
===================================================================
--- trunk/scripts/checkbashisms.pl      2008-03-01 11:59:04 UTC (rev 1090)
+++ trunk/scripts/checkbashisms.pl      2008-03-02 21:24:16 UTC (rev 1091)
@@ -24,6 +24,7 @@
 # MA 02111-1307, USA.
 
 use strict;
+use Getopt::Long;
 
 (my $progname = $0) =~ s|.*/||;
 
@@ -46,21 +47,24 @@
 EOF
 
 my $opt_echo = 0;
+my ($opt_help, $opt_version);
 
 ##
 ## 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; }
+GetOptions("help|h" => \$opt_help,
+          "version|v" => \$opt_version,
+          "newline|n" => \$opt_echo,
+           )
+    or die "Usage: $progname [options] filelist\nRun $progname --help for more 
details\n";
 
+if (int(@ARGV) == 0 or $opt_help) { print $usage; exit 0; }
+if ($opt_version) { print $version; exit 0; }
 
 my $status = 0;
 
 foreach my $filename (@ARGV) {
-    if ($filename eq '-n' or $filename eq '--newline') {
-       next;
-    } elsif (script_is_evil_and_wrong($filename)) {
+    if (script_is_evil_and_wrong($filename)) {
        warn "script $filename does not appear to be a /bin/sh script; 
skipping\n";
        next;
     }



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

Reply via email to