Added -v option.
This commit is contained in:
parent
f347d67dcf
commit
520a335ee6
|
@ -6,7 +6,7 @@ apppath - append directories to path
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
apppath [-c] directory...
|
apppath [-c] [-v variable] directory...
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
|
@ -22,6 +22,12 @@ prints the new path on stdout.
|
||||||
Check whether the directories exist before adding them. Nonexistent
|
Check whether the directories exist before adding them. Nonexistent
|
||||||
directories are silently ignored.
|
directories are silently ignored.
|
||||||
|
|
||||||
|
=item B<-v> I<variable>
|
||||||
|
|
||||||
|
Use the environment variable I<variable> instead of PATH.
|
||||||
|
This is useful for manipulating other PATH-like variables, like
|
||||||
|
LD_LIBRARY_PATH, PERL5LIB, etc.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=head1 AUTHOR
|
=head1 AUTHOR
|
||||||
|
@ -31,14 +37,19 @@ Peter J. Holzer <hjp@hjp.at>.
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
my $path = $ENV{PATH};
|
use Getopt::Long;
|
||||||
my @path = split(/:/, $path);
|
use Pod::Usage;
|
||||||
my $check;
|
|
||||||
|
|
||||||
if ($ARGV[0] eq '-c') {
|
my $check;
|
||||||
$check = 1;
|
my $debug;
|
||||||
shift;
|
my $var = 'PATH';
|
||||||
}
|
GetOptions("check" => \$check,
|
||||||
|
"debug" => \$debug,
|
||||||
|
"var=s" => \$var,
|
||||||
|
) or pod2usage(2);
|
||||||
|
|
||||||
|
my $path = $ENV{$var} || '';
|
||||||
|
my @path = split(/:/, $path);
|
||||||
|
|
||||||
if ($#ARGV == 0 && $ARGV[0] =~ /:/) {
|
if ($#ARGV == 0 && $ARGV[0] =~ /:/) {
|
||||||
@ARGV = split(/:/, $ARGV[0]);
|
@ARGV = split(/:/, $ARGV[0]);
|
||||||
|
|
|
@ -6,13 +6,25 @@ delpath - delete directories from path
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
delpath directory...
|
delpath [-v variable] directory...
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
delpath deletes the directories given as arguments from the PATH and
|
delpath deletes the directories given as arguments from the PATH and
|
||||||
prints the new path on stdout.
|
prints the new path on stdout.
|
||||||
|
|
||||||
|
=head1 OPTIONS
|
||||||
|
|
||||||
|
=over 4
|
||||||
|
|
||||||
|
=item B<-v> I<variable>
|
||||||
|
|
||||||
|
Use the environment variable I<variable> instead of PATH.
|
||||||
|
This is useful for manipulating other PATH-like variables, like
|
||||||
|
LD_LIBRARY_PATH, PERL5LIB, etc.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
=head1 AUTHOR
|
=head1 AUTHOR
|
||||||
|
|
||||||
Peter J. Holzer <hjp@hjp.at>.
|
Peter J. Holzer <hjp@hjp.at>.
|
||||||
|
@ -20,12 +32,20 @@ Peter J. Holzer <hjp@hjp.at>.
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
use Getopt::Long;
|
||||||
|
use Pod::Usage;
|
||||||
|
|
||||||
|
my $debug;
|
||||||
|
my $var = 'PATH';
|
||||||
|
GetOptions("debug" => \$debug,
|
||||||
|
"var=s" => \$var,
|
||||||
|
) or pod2usage(2);
|
||||||
|
|
||||||
if ($#ARGV == 0 && $ARGV[0] =~ /:/) {
|
if ($#ARGV == 0 && $ARGV[0] =~ /:/) {
|
||||||
@ARGV = split(/:/, $ARGV[0]);
|
@ARGV = split(/:/, $ARGV[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
my $path = $ENV{PATH};
|
my $path = $ENV{$var};
|
||||||
my @path = split(/:/, $path);
|
my @path = split(/:/, $path);
|
||||||
|
|
||||||
my %del;
|
my %del;
|
||||||
|
|
|
@ -6,7 +6,7 @@ preppath - prepend directories to path
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
preppath [-c] directory...
|
preppath [-c] [-v variable] directory...
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
|
@ -22,6 +22,12 @@ eliminates any duplicates and prints the new path on stdout.
|
||||||
Check whether the directories exist before adding them. Nonexistent
|
Check whether the directories exist before adding them. Nonexistent
|
||||||
directories are silently ignored.
|
directories are silently ignored.
|
||||||
|
|
||||||
|
=item B<-v> I<variable>
|
||||||
|
|
||||||
|
Use the environment variable I<variable> instead of PATH.
|
||||||
|
This is useful for manipulating other PATH-like variables, like
|
||||||
|
LD_LIBRARY_PATH, PERL5LIB, etc.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=head1 AUTHOR
|
=head1 AUTHOR
|
||||||
|
@ -31,14 +37,19 @@ Peter J. Holzer <hjp@hjp.at>.
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
my $path = $ENV{PATH};
|
use Getopt::Long;
|
||||||
my @path = split(/:/, $path);
|
use Pod::Usage;
|
||||||
my $check;
|
|
||||||
|
|
||||||
if ($ARGV[0] eq '-c') {
|
my $check;
|
||||||
$check = 1;
|
my $debug;
|
||||||
shift;
|
my $var = 'PATH';
|
||||||
}
|
GetOptions("check" => \$check,
|
||||||
|
"debug" => \$debug,
|
||||||
|
"var=s" => \$var,
|
||||||
|
) or pod2usage(2);
|
||||||
|
|
||||||
|
my $path = $ENV{$var} || '';
|
||||||
|
my @path = split(/:/, $path);
|
||||||
|
|
||||||
if ($#ARGV == 0 && $ARGV[0] =~ /:/) {
|
if ($#ARGV == 0 && $ARGV[0] =~ /:/) {
|
||||||
@ARGV = split(/:/, $ARGV[0]);
|
@ARGV = split(/:/, $ARGV[0]);
|
||||||
|
|
Loading…
Reference in New Issue