| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Term::ShellKit::Commands; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
require Term::ShellKit; |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
###################################################################### |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub eval ($) { |
|
8
|
0
|
|
|
0
|
1
|
0
|
my $input = shift; |
|
9
|
0
|
|
|
|
|
0
|
my @results = eval "package $Term::ShellKit::CurrentPackage; no strict qw( refs vars subs ); $input"; |
|
10
|
0
|
0
|
|
|
|
0
|
die $@ if $@; |
|
11
|
0
|
0
|
|
|
|
0
|
! scalar( @results ) ? '' : |
|
|
|
0
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
scalar( @results == 1 ) ? ( |
|
13
|
|
|
|
|
|
|
( ! defined $results[0] ) ? 'undef' : "$results[0]" |
|
14
|
|
|
|
|
|
|
) : |
|
15
|
|
|
|
|
|
|
join(', ', map { |
|
16
|
0
|
0
|
|
|
|
0
|
( ! defined ) ? 'undef' : ( ref $_ ) ? "$_" : "'$_'" |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
} @results ); |
|
18
|
|
|
|
|
|
|
} |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub package ($) { |
|
21
|
0
|
|
|
0
|
0
|
0
|
my $input = shift; |
|
22
|
0
|
|
|
|
|
0
|
$input =~ s/\;\s*$//; |
|
23
|
0
|
|
|
|
|
0
|
$Term::ShellKit::CurrentPackage = $input; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub exit { |
|
27
|
0
|
|
|
0
|
1
|
0
|
exit; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub kit { |
|
31
|
0
|
0
|
|
0
|
1
|
0
|
die "No kit name provided" unless ( scalar @_ ); |
|
32
|
0
|
|
|
|
|
0
|
map { Term::ShellKit::load_kit( $_ ) } @_; |
|
|
0
|
|
|
|
|
0
|
|
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
###################################################################### |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub execute ($) { |
|
38
|
0
|
|
|
0
|
1
|
0
|
my $command = shift; |
|
39
|
0
|
|
|
|
|
0
|
qx{$command}; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
###################################################################### |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub echo (;$) { |
|
45
|
1
|
|
|
1
|
1
|
5
|
shift; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
###################################################################### |
|
49
|
|
|
|
|
|
|
|
|
50
|
1
|
|
|
1
|
|
6
|
use vars qw( $PODViewer ); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
1221
|
|
|
51
|
|
|
|
|
|
|
$PODViewer ||= "Pod::Text" || "Pod::Text::TermCap"; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub help (;$) { |
|
54
|
0
|
|
0
|
0
|
1
|
|
my $topic = shift || 'Term::ShellKit::Commands'; |
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
$topic =~ s/kit /Term::ShellKit::/; |
|
57
|
0
|
0
|
|
|
|
|
if ( $topic =~ /^[\w\:]+$/ ) { |
|
58
|
0
|
|
|
|
|
|
(my $lib = $topic . '.pm' ) =~ s|::|/|go; |
|
59
|
0
|
0
|
|
|
|
|
if ( ! $::INC{$lib} ) { eval { local $SIG{__DIE__}; require $lib } } |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
60
|
0
|
0
|
|
|
|
|
$topic = $::INC{$lib} if ( $::INC{$lib} ); |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
Term::ShellKit::require_package( $PODViewer ); |
|
64
|
0
|
|
|
|
|
|
$PODViewer->new()->parse_from_file( $topic ); |
|
65
|
0
|
|
|
|
|
|
return; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
###################################################################### |
|
69
|
|
|
|
|
|
|
|
|
70
|
1
|
|
|
1
|
|
32
|
use vars qw( %CommandAliases ); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
371
|
|
|
71
|
|
|
|
|
|
|
%CommandAliases = ( |
|
72
|
|
|
|
|
|
|
'"' => 'echo', |
|
73
|
|
|
|
|
|
|
'$' => 'eval', |
|
74
|
|
|
|
|
|
|
'!' => 'execute', |
|
75
|
|
|
|
|
|
|
'q' => 'exit', |
|
76
|
|
|
|
|
|
|
'quit' => 'exit', |
|
77
|
|
|
|
|
|
|
'?' => 'help', |
|
78
|
|
|
|
|
|
|
); |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub alias { |
|
81
|
0
|
0
|
|
0
|
1
|
|
if ( scalar @_ ) { |
|
82
|
0
|
|
|
|
|
|
my $cmd = shift; |
|
83
|
0
|
0
|
|
|
|
|
if ( scalar @_ ) { |
|
84
|
0
|
|
|
|
|
|
$CommandAliases{ $cmd } = join ' ', @_; |
|
85
|
0
|
|
|
|
|
|
return; |
|
86
|
|
|
|
|
|
|
} else { |
|
87
|
0
|
|
|
|
|
|
$CommandAliases{ $cmd }; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
} else { |
|
90
|
0
|
|
|
|
|
|
map "$_: $CommandAliases{ $_ }", sort keys %CommandAliases; |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub _shell_rewrite { |
|
95
|
0
|
|
|
0
|
|
|
my $input = shift; |
|
96
|
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
$input =~ s/\A\s+//; |
|
98
|
0
|
|
|
|
|
|
my ($command, $args) = split(' ', $input, 2); |
|
99
|
0
|
0
|
|
|
|
|
my $alias = $CommandAliases{ $command } |
|
100
|
|
|
|
|
|
|
or return; |
|
101
|
|
|
|
|
|
|
|
|
102
|
0
|
0
|
|
|
|
|
return $alias . ( length($args) ? " $args" : '' ); |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
###################################################################### |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
1; |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
__END__ |