line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::spaceless; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
232195
|
use strict; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
5
|
1
|
|
|
1
|
|
27
|
use 5.010001; |
|
1
|
|
|
|
|
4
|
|
6
|
1
|
|
|
1
|
|
5
|
use Config; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
39
|
|
7
|
1
|
|
|
1
|
|
514
|
use Shell::Guess; |
|
1
|
|
|
|
|
2502
|
|
|
1
|
|
|
|
|
32
|
|
8
|
1
|
|
|
1
|
|
561
|
use Shell::Config::Generate qw( win32_space_be_gone ); |
|
1
|
|
|
|
|
3138
|
|
|
1
|
|
|
|
|
64
|
|
9
|
1
|
|
|
1
|
|
773
|
use Getopt::Long qw( GetOptions ); |
|
1
|
|
|
|
|
10611
|
|
|
1
|
|
|
|
|
4
|
|
10
|
1
|
|
|
1
|
|
817
|
use Pod::Usage qw( pod2usage ); |
|
1
|
|
|
|
|
39084
|
|
|
1
|
|
|
|
|
973
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# ABSTRACT: Convert PATH type environment variables to spaceless versions |
13
|
|
|
|
|
|
|
our $VERSION = '0.08'; # VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _running_shell |
17
|
|
|
|
|
|
|
{ |
18
|
3
|
|
|
3
|
|
7667
|
state $shell; |
19
|
3
|
100
|
|
|
|
18
|
$shell = Shell::Guess->running_shell unless defined $shell; |
20
|
3
|
|
|
|
|
1417
|
$shell; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub main |
24
|
|
|
|
|
|
|
{ |
25
|
6
|
|
|
6
|
0
|
86167
|
shift; |
26
|
6
|
|
|
|
|
22
|
local @ARGV = @_; |
27
|
6
|
|
|
|
|
59
|
my $shell; |
28
|
|
|
|
|
|
|
my $file; |
29
|
6
|
|
|
|
|
0
|
my $help; |
30
|
6
|
|
|
|
|
0
|
my $version; |
31
|
6
|
|
|
|
|
0
|
my $trim; |
32
|
6
|
|
|
|
|
13
|
my $cygwin = 1; |
33
|
6
|
|
|
|
|
49
|
my $expand; |
34
|
|
|
|
|
|
|
my $list; |
35
|
6
|
|
|
|
|
0
|
my $squash; |
36
|
|
|
|
|
|
|
|
37
|
6
|
|
|
|
|
80
|
my $config = Shell::Config::Generate->new; |
38
|
6
|
|
|
|
|
106
|
$config->echo_off; |
39
|
6
|
|
|
|
|
123
|
my $sep = quotemeta $Config{path_sep}; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
GetOptions( |
42
|
0
|
|
|
0
|
|
0
|
'csh' => sub { $shell = Shell::Guess->c_shell }, |
43
|
2
|
|
|
2
|
|
3472
|
'sh' => sub { $shell = Shell::Guess->bourne_shell }, |
44
|
0
|
|
|
0
|
|
0
|
'cmd' => sub { $shell = Shell::Guess->cmd_shell }, |
45
|
0
|
|
|
0
|
|
0
|
'command' => sub { $shell = Shell::Guess->command_shell }, |
46
|
0
|
|
|
0
|
|
0
|
'fish' => sub { $shell = Shell::Guess->fish_shell }, |
47
|
0
|
|
|
0
|
|
0
|
'korn' => sub { $shell = Shell::Guess->korn_shell }, |
48
|
0
|
|
|
0
|
|
0
|
'power' => sub { $shell = Shell::Guess->power_shell }, |
49
|
0
|
|
|
0
|
|
0
|
'login' => sub { $shell = Shell::Guess->login_shell }, |
50
|
0
|
|
|
0
|
|
0
|
'sep=s' => sub { $sep = quotemeta $_[1]; $config->set_path_sep($_[1]) }, |
|
0
|
|
|
|
|
0
|
|
51
|
0
|
|
|
0
|
|
0
|
'sep-in=s' => sub { $sep = quotemeta $_[1] }, |
52
|
0
|
|
|
0
|
|
0
|
'sep-out=s' => sub { $config->set_path_sep($_[1]) }, |
53
|
|
|
|
|
|
|
'squash|s' => \$squash, |
54
|
0
|
0
|
|
0
|
|
0
|
'no-cygwin' => sub { $cygwin = 0 if $^O eq 'cygwin' }, |
55
|
6
|
50
|
|
|
|
344
|
'list|l' => \$list, |
56
|
|
|
|
|
|
|
'expand|x' => \$expand, |
57
|
|
|
|
|
|
|
'trim|t' => \$trim, |
58
|
|
|
|
|
|
|
'f=s' => \$file, |
59
|
|
|
|
|
|
|
'help|h' => \$help, |
60
|
|
|
|
|
|
|
'version|v' => \$version, |
61
|
|
|
|
|
|
|
) || pod2usage(1); |
62
|
|
|
|
|
|
|
|
63
|
6
|
50
|
|
|
|
5019
|
if($help) |
64
|
|
|
|
|
|
|
{ |
65
|
0
|
|
|
|
|
0
|
pod2usage({ -verbose => 2 }); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
6
|
100
|
|
|
|
17
|
if($version) |
69
|
|
|
|
|
|
|
{ |
70
|
2
|
|
50
|
|
|
93
|
say 'App::spaceless version ', ($App::spaceless::VERSION // 'dev'); |
71
|
2
|
|
|
|
|
29
|
return 1; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
4
|
100
|
|
|
|
17
|
$shell = _running_shell() unless defined $shell; |
75
|
|
|
|
|
|
|
|
76
|
4
|
50
|
33
|
0
|
|
47
|
my $filter = $^O eq 'cygwin' && $shell->is_win32 ? sub { map { Cygwin::posix_to_win_path($_) } @_ } : sub { @_ }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
4
|
|
|
|
|
64
|
|
77
|
|
|
|
|
|
|
|
78
|
4
|
100
|
|
|
|
22
|
@ARGV = ('PATH') unless @ARGV; |
79
|
|
|
|
|
|
|
|
80
|
4
|
50
|
|
0
|
|
33
|
my $to_long = $^O eq 'cygwin' ? sub { Cygwin::win_to_posix_path(Win32::GetLongPathName(Cygwin::posix_to_win_path($_))) } : sub { Win32::GetLongPathName($_[0]) }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
81
|
|
|
|
|
|
|
|
82
|
4
|
50
|
|
0
|
|
29
|
my $mutator = $expand ? sub { map { $to_long->($_) } @_ } : sub { win32_space_be_gone(grep { -e $_ } @_) }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
4
|
|
|
|
|
10
|
|
|
30
|
|
|
|
|
395
|
|
83
|
|
|
|
|
|
|
|
84
|
4
|
|
|
|
|
21
|
foreach my $var (@ARGV) |
85
|
|
|
|
|
|
|
{ |
86
|
|
|
|
|
|
|
my @path = $filter->($mutator->( |
87
|
31
|
100
|
|
|
|
89
|
grep { $trim ? -d $_ : 1 } |
88
|
31
|
50
|
|
|
|
57
|
grep { $cygwin ? 1 : $_ =~ qr{^([A-Za-z]:|/cygdrive/[A-Za-z])} } |
89
|
4
|
|
50
|
|
|
48
|
split /$sep/, $ENV{$var} // '' |
90
|
|
|
|
|
|
|
)); |
91
|
|
|
|
|
|
|
|
92
|
4
|
50
|
|
|
|
17
|
if($squash) |
93
|
|
|
|
|
|
|
{ |
94
|
0
|
|
|
|
|
0
|
my %path; |
95
|
0
|
|
|
|
|
0
|
@path = grep { !$path{$_}++ } @path; |
|
0
|
|
|
|
|
0
|
|
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
4
|
|
|
|
|
20
|
$config->set_path( $var => @path ); |
99
|
4
|
50
|
|
|
|
72
|
do { say $_ for @path } if $list; |
|
0
|
|
|
|
|
0
|
|
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
4
|
50
|
|
|
|
12
|
unless($list) |
103
|
|
|
|
|
|
|
{ |
104
|
4
|
100
|
|
|
|
9
|
if(defined $file) |
105
|
|
|
|
|
|
|
{ |
106
|
1
|
|
|
|
|
5
|
$config->generate_file($shell, $file); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
else |
109
|
|
|
|
|
|
|
{ |
110
|
3
|
|
|
|
|
25
|
print $config->generate($shell); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
4
|
|
|
|
|
1342
|
return 0; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
1; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
__END__ |