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
|
This is useful for manipulating other PATH-like variables, like
|
||||||
LD_LIBRARY_PATH, PERL5LIB, etc.
|
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
|
=back
|
||||||
|
|
||||||
=head1 AUTHOR
|
=head1 AUTHOR
|
||||||
|
@ -42,9 +52,13 @@ use Getopt::Long;
|
||||||
my $check;
|
my $check;
|
||||||
my $debug;
|
my $debug;
|
||||||
my $var = 'PATH';
|
my $var = 'PATH';
|
||||||
|
my $export;
|
||||||
|
my $private;
|
||||||
GetOptions("check" => \$check,
|
GetOptions("check" => \$check,
|
||||||
"debug" => \$debug,
|
"debug" => \$debug,
|
||||||
"var=s" => \$var,
|
"var=s" => \$var,
|
||||||
|
"export" => \$export,
|
||||||
|
"private" => \$private,
|
||||||
) or do {
|
) or do {
|
||||||
require Pod::Usage;
|
require Pod::Usage;
|
||||||
import Pod::Usage;
|
import Pod::Usage;
|
||||||
|
@ -64,4 +78,10 @@ nd: for my $nd (@ARGV) {
|
||||||
}
|
}
|
||||||
push @path, $nd if (!$check || -d $nd);
|
push @path, $nd if (!$check || -d $nd);
|
||||||
}
|
}
|
||||||
|
if ($export) {
|
||||||
|
print "export ";
|
||||||
|
}
|
||||||
|
if ($export || $private) {
|
||||||
|
print "$var=";
|
||||||
|
}
|
||||||
print join(':', @path), "\n";
|
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
|
This is useful for manipulating other PATH-like variables, like
|
||||||
LD_LIBRARY_PATH, PERL5LIB, etc.
|
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
|
=back
|
||||||
|
|
||||||
=head1 AUTHOR
|
=head1 AUTHOR
|
||||||
|
@ -37,8 +47,12 @@ use Pod::Usage;
|
||||||
|
|
||||||
my $debug;
|
my $debug;
|
||||||
my $var = 'PATH';
|
my $var = 'PATH';
|
||||||
|
my $export;
|
||||||
|
my $private;
|
||||||
GetOptions("debug" => \$debug,
|
GetOptions("debug" => \$debug,
|
||||||
"var=s" => \$var,
|
"var=s" => \$var,
|
||||||
|
"export" => \$export,
|
||||||
|
"private" => \$private,
|
||||||
) or pod2usage(2);
|
) or pod2usage(2);
|
||||||
|
|
||||||
if ($#ARGV == 0 && $ARGV[0] =~ /:/) {
|
if ($#ARGV == 0 && $ARGV[0] =~ /:/) {
|
||||||
|
@ -55,4 +69,10 @@ for (@del{@ARGV}) {
|
||||||
|
|
||||||
@path = grep { !$del{$_} } @path;
|
@path = grep { !$del{$_} } @path;
|
||||||
|
|
||||||
|
if ($export) {
|
||||||
|
print "export ";
|
||||||
|
}
|
||||||
|
if ($export || $private) {
|
||||||
|
print "$var=";
|
||||||
|
}
|
||||||
print join(':', @path), "\n";
|
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
|
This is useful for manipulating other PATH-like variables, like
|
||||||
LD_LIBRARY_PATH, PERL5LIB, etc.
|
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
|
=back
|
||||||
|
|
||||||
=head1 AUTHOR
|
=head1 AUTHOR
|
||||||
|
@ -42,9 +52,13 @@ use Getopt::Long;
|
||||||
my $check;
|
my $check;
|
||||||
my $debug;
|
my $debug;
|
||||||
my $var = 'PATH';
|
my $var = 'PATH';
|
||||||
|
my $export;
|
||||||
|
my $private;
|
||||||
GetOptions("check" => \$check,
|
GetOptions("check" => \$check,
|
||||||
"debug" => \$debug,
|
"debug" => \$debug,
|
||||||
"var=s" => \$var,
|
"var=s" => \$var,
|
||||||
|
"export" => \$export,
|
||||||
|
"private" => \$private,
|
||||||
) or do {
|
) or do {
|
||||||
require Pod::Usage;
|
require Pod::Usage;
|
||||||
import Pod::Usage;
|
import Pod::Usage;
|
||||||
|
@ -67,4 +81,11 @@ for my $d (@ARGV, @path) {
|
||||||
$seen{$d} = 1;
|
$seen{$d} = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($export) {
|
||||||
|
print "export ";
|
||||||
|
}
|
||||||
|
if ($export || $private) {
|
||||||
|
print "$var=";
|
||||||
|
}
|
||||||
print join(':', @newpath), "\n";
|
print join(':', @newpath), "\n";
|
||||||
|
|
Loading…
Reference in New Issue