Skip to content

Commit

Permalink
removed bug, added support functions
Browse files Browse the repository at this point in the history
Invoking without arguments does not give error any more.

Added support functions for quick setting of PERL5LIB.
  • Loading branch information
polettix committed May 19, 2015
1 parent 29b835a commit 0704220
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions wrapperl
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ sub action_exec {
}

sub dispatch_wrapperl {
action_exec() unless @ARGV;

my $first = $ARGV[0] || '';
if ($first =~ m{\A(?: -e | --env )\z}mxs) {
shift @ARGV;
Expand All @@ -134,6 +136,30 @@ sub dispatch_wrapperl {
action_exec(realpath($ARGV[0]));
} ## end sub dispatch_wrapperl

### Handy functions for path management in wrapperl.env ###

sub path_child {
my ($parent, @child) = @_;
my ($v, $d) = ref($parent) ? @$parent : splitpath($parent, 'no-file');
my $filename = pop @child;
$d = catdir(splitdir($d), @child) if @child;
return catpath($v, $d, $filename);
}

sub path_siblings_list {
my $r = shift;
my ($v, $d) = splitpath($r);
return map {
file_name_is_absolute($_) ? $_
: path_child([$v, $d], ref($_) ? @$_ : $_);
} @_;
}

sub set_PERL5LIB_from_siblings {
my $file = rel2abs((caller(1))[6]);
$ENV{PERL5LIB} = join ':', path_siblings_list($file, @_);
}

__END__

=pod
Expand Down

0 comments on commit 0704220

Please sign in to comment.