line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# -*- perl -*- |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# Author: Slaven Rezic |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Copyright (C) 2017 Slaven Rezic. All rights reserved. |
7
|
|
|
|
|
|
|
# This package is free software; you can redistribute it and/or |
8
|
|
|
|
|
|
|
# modify it under the same terms as Perl itself. |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# Mail: slaven@rezic.de |
11
|
|
|
|
|
|
|
# WWW: http://www.rezic.de/eserte/ |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
package Doit::Extcmd; |
15
|
|
|
|
|
|
|
|
16
|
7
|
|
|
7
|
|
3227
|
use strict; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
208
|
|
17
|
7
|
|
|
7
|
|
36
|
use warnings; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
273
|
|
18
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
19
|
|
|
|
|
|
|
|
20
|
7
|
|
|
7
|
|
36
|
use Exporter 'import'; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
4274
|
|
21
|
|
|
|
|
|
|
our @EXPORT_OK = qw(is_in_path); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# REPO BEGIN |
24
|
|
|
|
|
|
|
# REPO NAME is_in_path /Users/eserte/src/srezic-repository |
25
|
|
|
|
|
|
|
# REPO MD5 e18e6687a056e4a3cbcea4496aaaa1db |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub is_in_path { |
28
|
7
|
|
|
7
|
0
|
368296
|
my($prog) = @_; |
29
|
7
|
50
|
|
|
|
39
|
if (file_name_is_absolute($prog)) { |
30
|
0
|
0
|
|
|
|
0
|
if ($^O eq 'MSWin32') { |
31
|
0
|
0
|
0
|
|
|
0
|
return $prog if (-f $prog && -x $prog); |
32
|
0
|
0
|
0
|
|
|
0
|
return "$prog.bat" if (-f "$prog.bat" && -x "$prog.bat"); |
33
|
0
|
0
|
0
|
|
|
0
|
return "$prog.com" if (-f "$prog.com" && -x "$prog.com"); |
34
|
0
|
0
|
0
|
|
|
0
|
return "$prog.exe" if (-f "$prog.exe" && -x "$prog.exe"); |
35
|
0
|
0
|
0
|
|
|
0
|
return "$prog.cmd" if (-f "$prog.cmd" && -x "$prog.cmd"); |
36
|
|
|
|
|
|
|
} else { |
37
|
0
|
0
|
0
|
|
|
0
|
return $prog if -f $prog and -x $prog; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
7
|
|
|
|
|
74
|
require Config; |
41
|
7
|
|
|
|
|
19
|
%Config::Config = %Config::Config if 0; # cease -w |
42
|
7
|
|
50
|
|
|
194
|
my $sep = $Config::Config{'path_sep'} || ':'; |
43
|
7
|
|
|
|
|
143
|
foreach (split(/$sep/o, $ENV{PATH})) { |
44
|
51
|
50
|
|
|
|
168
|
if ($^O eq 'MSWin32') { |
45
|
|
|
|
|
|
|
# maybe use $ENV{PATHEXT} like maybe_command in ExtUtils/MM_Win32.pm? |
46
|
0
|
0
|
0
|
|
|
0
|
return "$_\\$prog" if (-f "$_\\$prog" && -x "$_\\$prog"); |
47
|
0
|
0
|
0
|
|
|
0
|
return "$_\\$prog.bat" if (-f "$_\\$prog.bat" && -x "$_\\$prog.bat"); |
48
|
0
|
0
|
0
|
|
|
0
|
return "$_\\$prog.com" if (-f "$_\\$prog.com" && -x "$_\\$prog.com"); |
49
|
0
|
0
|
0
|
|
|
0
|
return "$_\\$prog.exe" if (-f "$_\\$prog.exe" && -x "$_\\$prog.exe"); |
50
|
0
|
0
|
0
|
|
|
0
|
return "$_\\$prog.cmd" if (-f "$_\\$prog.cmd" && -x "$_\\$prog.cmd"); |
51
|
|
|
|
|
|
|
} else { |
52
|
51
|
100
|
66
|
|
|
925
|
return "$_/$prog" if (-x "$_/$prog" && !-d "$_/$prog"); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
3
|
|
|
|
|
21
|
undef; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
# REPO END |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# REPO BEGIN |
60
|
|
|
|
|
|
|
# REPO NAME file_name_is_absolute /Users/eserte/src/srezic-repository |
61
|
|
|
|
|
|
|
# REPO MD5 89d0fdf16d11771f0f6e82c7d0ebf3a8 |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
BEGIN { |
64
|
7
|
50
|
|
7
|
|
27
|
if (eval { require File::Spec; defined &File::Spec::file_name_is_absolute }) { |
|
7
|
|
|
|
|
41
|
|
|
7
|
|
|
|
|
33
|
|
65
|
0
|
|
|
|
|
0
|
*file_name_is_absolute = \&File::Spec::file_name_is_absolute; |
66
|
|
|
|
|
|
|
} else { |
67
|
|
|
|
|
|
|
*file_name_is_absolute = sub { |
68
|
7
|
|
|
7
|
|
23
|
my $file = shift; |
69
|
7
|
|
|
|
|
20
|
my $r; |
70
|
7
|
50
|
|
|
|
59
|
if ($^O eq 'MSWin32') { |
71
|
0
|
|
|
|
|
0
|
$r = ($file =~ m;^([a-z]:(/|\\)|\\\\|//);i); |
72
|
|
|
|
|
|
|
} else { |
73
|
7
|
|
|
|
|
44
|
$r = ($file =~ m|^/|); |
74
|
|
|
|
|
|
|
} |
75
|
7
|
|
|
|
|
39
|
$r; |
76
|
7
|
|
|
|
|
236
|
}; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
# REPO END |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__END__ |