From f249ffcbf75191c317dfb4fbfa7ff3041a6e38bb Mon Sep 17 00:00:00 2001 From: Rafael Garcia-Suarez Date: Tue, 29 Mar 2005 08:45:14 +0000 Subject: Display help message when invoked without arguments; trim spaces from media file (bug #15028); make command-line option more robust --- gurpmi.addmedia | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/gurpmi.addmedia b/gurpmi.addmedia index feb72bc3..2b458c96 100755 --- a/gurpmi.addmedia +++ b/gurpmi.addmedia @@ -20,28 +20,27 @@ # # $Id$ - use strict; -use lib qw(/usr/lib/libDrakX); -use common; -BEGIN { #- we want to run this code standalone.pm can output its sucking help - "@ARGV" =~ /-h/ and do { - printf "usage: gurpmi.addmedia [options] [with ] +BEGIN { + @ARGV == 0 || "@ARGV" =~ /-h/ and do { + print "usage: gurpmi.addmedia [options] [with ] where is one of - file:// - ftp://:@/ with - ftp:/// with - http:/// with - removable:// - + file:// + ftp://:@/ with + ftp:/// with + http:/// with + removable:// and [options] are from - --update - create an update medium. -"; + --update create an update medium. +"; exit(0); }; } +use lib qw(/usr/lib/libDrakX); +use common; + require_root_capability(); use rpmdrake; @@ -55,12 +54,12 @@ $::isStandalone = 1; my $fromfile; if (@ARGV == 1 && $ARGV[0] =~ /\.urpmi-media$/) { - @ARGV = split /\n/, cat_($ARGV[0]); + @ARGV = map { s/^\s*//; s/\s*$//; $_ } split /\n/, cat_($ARGV[0]); $fromfile = 1; } my $update = 0; -if ($ARGV[0] =~ /-?-update/) { +if ($ARGV[0] =~ /^-?-update/) { $update = 1; unshift @ARGV; } -- cgit v1.2.1