From 270c257f81665d1bcfab1ca4a3d831b5bcabc034 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 5 Jan 2017 17:40:45 +0000 Subject: badcommit-fixup: reorganise arg parsing --- badcommit-fixup | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/badcommit-fixup b/badcommit-fixup index b8cb88a..ca2e0df 100755 --- a/badcommit-fixup +++ b/badcommit-fixup @@ -1,7 +1,7 @@ #!/usr/bin/perl -w # usage: -# .../badcommit-fixup --test +# .../badcommit-fixup [-- --test # .../badcommit-fixup --real use strict; @@ -10,10 +10,19 @@ use POSIX; use IPC::Open2; use Data::Dumper; -die unless "@ARGV" eq "--test" or "@ARGV" eq "--real"; +my $real; -my ($modeopt) = @ARGV; -my $real = ($modeopt eq '--real'); +foreach my $a (@ARGV) { + if ($a eq '--test') { + $real = 0; + } elsif ($a eq '--real') { + $real = 1; + } else { + die "$a ?"; + } +} + +die unless defined $real; my $gcfpid = open2 \*GCFO, \*GCFI, 'git cat-file --batch' or die $!; -- cgit v1.2.3