From 59e958e160b75036e42d71498eb39f28357af72b Mon Sep 17 00:00:00 2001 From: "Peter J. Holzer" Date: Thu, 13 Sep 2018 19:05:06 +0200 Subject: [PATCH] Add -r (--reverse) option. --- pathtools/preppath.pl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pathtools/preppath.pl b/pathtools/preppath.pl index a096cf8..bef0a0d 100755 --- a/pathtools/preppath.pl +++ b/pathtools/preppath.pl @@ -38,6 +38,12 @@ Print a complete variable assignment statement ready to be eval'd by a POSIX shell. Unlike the C<-e> option this does not prepend the export keyword, so the variable is private unless it is exported elsewhere. +=item B<-r> + +Reverse order of arguments. This is useful if you have several versions +of a software installed and you want the one with the highest version +number first in your path. + =back =head1 AUTHOR @@ -54,11 +60,13 @@ my $debug; my $var = 'PATH'; my $export; my $private; +my $reverse; GetOptions("check" => \$check, "debug" => \$debug, "var=s" => \$var, "export" => \$export, "private" => \$private, + "reverse" => \$reverse, ) or do { require Pod::Usage; import Pod::Usage; @@ -72,6 +80,10 @@ if ($#ARGV == 0 && $ARGV[0] =~ /:/) { @ARGV = split(/:/, $ARGV[0]); } +if ($reverse) { + @ARGV = reverse @ARGV; +} + my %seen; my @newpath;