aboutsummaryrefslogtreecommitdiffstats
path: root/iurt_root_command
diff options
context:
space:
mode:
authorOlivier Blin <blino@mageia.org>2010-11-04 11:56:03 +0000
committerOlivier Blin <blino@mageia.org>2010-11-04 11:56:03 +0000
commit6a4d1db679d685d6c95b103bc678087f23e511eb (patch)
tree17d185654941b8af0676565b54be34f1e6ea56f7 /iurt_root_command
parent2447c4aaeaf0eb4d45b732cdca4a40726628be78 (diff)
downloadiurt-6a4d1db679d685d6c95b103bc678087f23e511eb.tar
iurt-6a4d1db679d685d6c95b103bc678087f23e511eb.tar.gz
iurt-6a4d1db679d685d6c95b103bc678087f23e511eb.tar.bz2
iurt-6a4d1db679d685d6c95b103bc678087f23e511eb.tar.xz
iurt-6a4d1db679d685d6c95b103bc678087f23e511eb.zip
handle commands with unhandled options in a more generic way
Diffstat (limited to 'iurt_root_command')
-rwxr-xr-xiurt_root_command12
1 files changed, 8 insertions, 4 deletions
diff --git a/iurt_root_command b/iurt_root_command
index 6de4785..e54ce76 100755
--- a/iurt_root_command
+++ b/iurt_root_command
@@ -157,6 +157,10 @@ $run{todo} = [];
\&urpmi, "Run urpmi in chroot" ],
);
+my %commands_with_more_args = (
+ "--urpmi" => [ \&urpmi, "urpmi" ],
+);
+
open(my $LOG, ">&STDERR");
$run{LOG} = sub { print $LOG @_ };
@@ -165,11 +169,11 @@ plog_init($program_name, $LOG, $run{verbose});
my $todo;
-# (blino) do not use mkcd to parse urpmi command line
-# I fail to make it no parse arguments after -- on command line
-if ($ARGV[0] eq '--urpmi') {
+# (blino) do not use mkcd to parse complicated command lines with unhandled options
+# I fail to make mkcd not parse arguments after -- on command line
+if (my $command = $commands_with_more_args{$ARGV[0]}) {
my (undef, @options) = @ARGV;
- $todo = [ [ \&urpmi, \@options, "urpmi" ] ];
+ $todo = [ [ $command->[0], \@options, $command->[1] ] ];
} else {
$todo = parseCommandLine($program_name, \@ARGV, \@params);
@ARGV and usage($program_name, \@params, "@ARGV, too many arguments");