| 1 | package ExtUtils::Helpers::Unix; | ||||||||||||||||||||||||||||
| 2 | 4 | $ExtUtils::Helpers::Unix::VERSION = '0.025'; | |||||||||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use Exporter 5.57 'import'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 4 | our @EXPORT = qw/make_executable detildefy/; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use Carp qw/croak/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use Config; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 4 | ▶ | my $layer = $] >= 5.008001 ? ":raw" : ""; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | sub make_executable { | ||||||||||||||||||||||||||||
| 15 | 1 | ▶ | my $filename = shift; | ||||||||||||||||||||||||||
|
Subroutine
make_executable: called CC=7 SCAR=20.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 16 | 1 | my $current_mode = (stat $filename)[2] + 0; | |||||||||||||||||||||||||||
| 17 | 1 | ▶ | if (-T $filename) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 18 | 1 | open my $fh, "<$layer", $filename; | |||||||||||||||||||||||||||
| 19 | 1 | my @lines = <$fh>; | |||||||||||||||||||||||||||
| 20 | 1 | ▶ | if (@lines and $lines[0] =~ s{ \A \#! \s* (?:/\S+/)? perl \b (.*) \z }{$Config{startperl}$1}xms) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@lines and $lines[0] =~ s[ \A \#! \s* (?:/\S+/)? perl \b (.*) \z ][$ExtUtils::Helpers::Unix::Config{"startperl"}$1]msx
MC/DC0%0/2
@lines and $lines[0] =~ s[ \A \#! \s* (?:/\S+/)? perl \b (.*) \z ][$ExtUtils::Helpers::Unix::Config{"startperl"}$1]msx
@lines
$lines[0] =~ s[ \A \#! \s* (?:/\S+/)? perl \b (.*) \z ][$ExtUtils::Helpers::Unix::Config{"startperl"}$1]msx
Truth table33%1/3
A and B
A= @linesB= $lines[0] =~ s[ \A \#! \s* (?:/\S+/)? perl \b (.*) \z ][$ExtUtils::Helpers::Unix::Config{"startperl"}$1]msx
| |||||||||||||||||||||||||||||
| 21 | 1 | ▶ | open my $out, ">$layer", "$filename.new" or croak "Couldn't open $filename.new: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | 1 | print $out @lines; | |||||||||||||||||||||||||||
| 23 | 1 | close $out; | |||||||||||||||||||||||||||
| 24 | 1 | ▶ | rename $filename, "$filename.bak" or croak "Couldn't rename $filename to $filename.bak"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | 1 | ▶ | rename "$filename.new", $filename or croak "Couldn't rename $filename.new to $filename"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 1 | unlink "$filename.bak"; | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | 1 | chmod $current_mode | oct(111), $filename; | |||||||||||||||||||||||||||
| 30 | 1 | return; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | sub detildefy { | ||||||||||||||||||||||||||||
| 34 | 9 | ▶ | my $value = shift; | ||||||||||||||||||||||||||
|
Subroutine
detildefy: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 35 | # tilde with optional username | ||||||||||||||||||||||||||||
| 36 | 9 | for ($value) { | |||||||||||||||||||||||||||
| 37 | 9 | ▶ | s{ ^ ~ (?= /|$)} [ $ENV{HOME} || (getpwuid $>)[7] ]ex or # tilde without user name | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 38 | 3 | ▶ | s{ ^ ~ ([^/]+) (?= /|$) } { (getpwnam $1)[7] || "~$1" }ex; # tilde with user name | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | 9 | return $value; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 4 | 1; | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | # ABSTRACT: Unix specific helper bits | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | __END__ | ||||||||||||||||||||||||||||