diff options
author | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2005-03-29 08:45:14 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2005-03-29 08:45:14 +0000 |
commit | f249ffcbf75191c317dfb4fbfa7ff3041a6e38bb (patch) | |
tree | efde641174a986ddfd40f12ff6318baf339ea201 /gurpmi.addmedia | |
parent | c935486ca6c421cc9ec6d86d9d0684b72e2da9c0 (diff) | |
download | rpmdrake-f249ffcbf75191c317dfb4fbfa7ff3041a6e38bb.tar rpmdrake-f249ffcbf75191c317dfb4fbfa7ff3041a6e38bb.tar.gz rpmdrake-f249ffcbf75191c317dfb4fbfa7ff3041a6e38bb.tar.bz2 rpmdrake-f249ffcbf75191c317dfb4fbfa7ff3041a6e38bb.tar.xz rpmdrake-f249ffcbf75191c317dfb4fbfa7ff3041a6e38bb.zip |
Display help message when invoked without arguments; trim spaces from media
file (bug #15028); make command-line option more robust
Diffstat (limited to 'gurpmi.addmedia')
-rwxr-xr-x | gurpmi.addmedia | 31 |
1 files 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] <name> <url> [with <relative_path>] +BEGIN { + @ARGV == 0 || "@ARGV" =~ /-h/ and do { + print "usage: gurpmi.addmedia [options] <name> <url> [with <relative_path>] where <url> is one of - file://<path> - ftp://<login>:<password>@<host>/<path> with <relative filename of hdlist> - ftp://<host>/<path> with <relative filename of hdlist> - http://<host>/<path> with <relative filename of hdlist> - removable://<path> - + file://<path> + ftp://<login>:<password>@<host>/<path> with <relative filename of hdlist> + ftp://<host>/<path> with <relative filename of hdlist> + http://<host>/<path> with <relative filename of hdlist> + removable://<path> 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; } |