Added -e (--export) and -p (--private) options.
This commit is contained in:
parent
1419d9dbc3
commit
c5acc52b65
|
@ -28,6 +28,16 @@ Use the environment variable I<variable> instead of PATH.
|
|||
This is useful for manipulating other PATH-like variables, like
|
||||
LD_LIBRARY_PATH, PERL5LIB, etc.
|
||||
|
||||
=item B<-e>
|
||||
|
||||
Print a complete export statement ready to be eval'd by a POSIX shell.
|
||||
|
||||
=item B<-p>
|
||||
|
||||
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.
|
||||
|
||||
=back
|
||||
|
||||
=head1 AUTHOR
|
||||
|
@ -42,9 +52,13 @@ use Getopt::Long;
|
|||
my $check;
|
||||
my $debug;
|
||||
my $var = 'PATH';
|
||||
my $export;
|
||||
my $private;
|
||||
GetOptions("check" => \$check,
|
||||
"debug" => \$debug,
|
||||
"var=s" => \$var,
|
||||
"export" => \$export,
|
||||
"private" => \$private,
|
||||
) or do {
|
||||
require Pod::Usage;
|
||||
import Pod::Usage;
|
||||
|
@ -64,4 +78,10 @@ nd: for my $nd (@ARGV) {
|
|||
}
|
||||
push @path, $nd if (!$check || -d $nd);
|
||||
}
|
||||
if ($export) {
|
||||
print "export ";
|
||||
}
|
||||
if ($export || $private) {
|
||||
print "$var=";
|
||||
}
|
||||
print join(':', @path), "\n";
|
||||
|
|
|
@ -23,6 +23,16 @@ Use the environment variable I<variable> instead of PATH.
|
|||
This is useful for manipulating other PATH-like variables, like
|
||||
LD_LIBRARY_PATH, PERL5LIB, etc.
|
||||
|
||||
=item B<-e>
|
||||
|
||||
Print a complete export statement ready to be eval'd by a POSIX shell.
|
||||
|
||||
=item B<-p>
|
||||
|
||||
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.
|
||||
|
||||
=back
|
||||
|
||||
=head1 AUTHOR
|
||||
|
@ -37,8 +47,12 @@ use Pod::Usage;
|
|||
|
||||
my $debug;
|
||||
my $var = 'PATH';
|
||||
my $export;
|
||||
my $private;
|
||||
GetOptions("debug" => \$debug,
|
||||
"var=s" => \$var,
|
||||
"export" => \$export,
|
||||
"private" => \$private,
|
||||
) or pod2usage(2);
|
||||
|
||||
if ($#ARGV == 0 && $ARGV[0] =~ /:/) {
|
||||
|
@ -55,4 +69,10 @@ for (@del{@ARGV}) {
|
|||
|
||||
@path = grep { !$del{$_} } @path;
|
||||
|
||||
if ($export) {
|
||||
print "export ";
|
||||
}
|
||||
if ($export || $private) {
|
||||
print "$var=";
|
||||
}
|
||||
print join(':', @path), "\n";
|
||||
|
|
|
@ -28,6 +28,16 @@ Use the environment variable I<variable> instead of PATH.
|
|||
This is useful for manipulating other PATH-like variables, like
|
||||
LD_LIBRARY_PATH, PERL5LIB, etc.
|
||||
|
||||
=item B<-e>
|
||||
|
||||
Print a complete export statement ready to be eval'd by a POSIX shell.
|
||||
|
||||
=item B<-p>
|
||||
|
||||
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.
|
||||
|
||||
=back
|
||||
|
||||
=head1 AUTHOR
|
||||
|
@ -42,9 +52,13 @@ use Getopt::Long;
|
|||
my $check;
|
||||
my $debug;
|
||||
my $var = 'PATH';
|
||||
my $export;
|
||||
my $private;
|
||||
GetOptions("check" => \$check,
|
||||
"debug" => \$debug,
|
||||
"var=s" => \$var,
|
||||
"export" => \$export,
|
||||
"private" => \$private,
|
||||
) or do {
|
||||
require Pod::Usage;
|
||||
import Pod::Usage;
|
||||
|
@ -67,4 +81,11 @@ for my $d (@ARGV, @path) {
|
|||
$seen{$d} = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ($export) {
|
||||
print "export ";
|
||||
}
|
||||
if ($export || $private) {
|
||||
print "$var=";
|
||||
}
|
||||
print join(':', @newpath), "\n";
|
||||
|
|
Loading…
Reference in New Issue