[Reproducible-commits] [strip-nondeterminism] 01/05: Use Getopt::Long more idiomatically to process command line args

Andrew Ayer agwa at andrewayer.name
Wed Jun 8 04:50:00 UTC 2016


This is an automated email from the git hooks/post-receive script.

agwa-guest pushed a commit to branch mine
in repository strip-nondeterminism.

commit 22d834ffb7e4152380339a009a6681e1c688dbfa
Author: Andrew Ayer <agwa at andrewayer.name>
Date:   Tue Jun 16 10:26:25 2015 -0700

    Use Getopt::Long more idiomatically to process command line args
---
 bin/strip-nondeterminism | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/bin/strip-nondeterminism b/bin/strip-nondeterminism
index a42f72d..3d185c7 100755
--- a/bin/strip-nondeterminism
+++ b/bin/strip-nondeterminism
@@ -31,18 +31,20 @@ my $cmd = $0;
 $cmd =~ s/.*\///;
 my $usage = "Usage: $cmd [-t|--type FILETYPE] [-T|--timestamp SECONDS] FILENAME\n";
 
-my @opspec = (
-	'type|t=s', 'help|h', 'version|V', 'timestamp|T=i'
-);
-my $glop = {};
-GetOptions($glop, @opspec) || die $usage;
-
-if ($glop->{help}) {
+my ($filetype, $timestamp, $want_help, $want_version);
+my $getopt = Getopt::Long::Parser->new;
+$getopt->configure(qw(no_ignore_case permute bundling));
+$getopt->getoptions('type|t=s', \$filetype,
+		    'timestamp|T=i', \$timestamp,
+		    'help|h', \$want_help,
+		    'version|V', \$want_version) or die $usage;
+
+if ($want_help) {
 	print $usage;
 	exit 0;
 }
 
-if ($glop->{version}) {
+if ($want_version) {
 	print "$cmd version $File::StripNondeterminism::VERSION\n";
 	exit 0;
 }
@@ -50,15 +52,15 @@ if ($glop->{version}) {
 $ENV{'TZ'} = 'UTC';
 tzset();
 
-$File::StripNondeterminism::canonical_time = $glop->{timestamp};
+$File::StripNondeterminism::canonical_time = $timestamp;
 
 die $usage if @ARGV == 0;
 
 for my $filename (@ARGV) {
 	my $normalizer;
-	if ($glop->{type}) {
-		$normalizer = File::StripNondeterminism::get_normalizer_by_name($glop->{type});
-		die $glop->{type} . ": Unknown file type\n" unless $normalizer;
+	if (defined $filetype) {
+		$normalizer = File::StripNondeterminism::get_normalizer_by_name($filetype);
+		die "$filetype: Unknown file type\n" unless $normalizer;
 	} else {
 		$normalizer = File::StripNondeterminism::get_normalizer_for_file($filename);
 		next unless $normalizer;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/strip-nondeterminism.git



More information about the Reproducible-commits mailing list