| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::SSH::Perl::Util::Term; |
|
2
|
5
|
|
|
5
|
|
37
|
use strict; |
|
|
5
|
|
|
|
|
19
|
|
|
|
5
|
|
|
|
|
159
|
|
|
3
|
5
|
|
|
5
|
|
24
|
use warnings; |
|
|
5
|
|
|
|
|
10
|
|
|
|
5
|
|
|
|
|
1655
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub _prompt { |
|
6
|
0
|
|
|
0
|
|
|
my($prompt, $def, $echo) = @_; |
|
7
|
0
|
0
|
|
|
|
|
unless ($echo) { |
|
8
|
0
|
|
|
|
|
|
return _read_passphrase($prompt); |
|
9
|
|
|
|
|
|
|
} |
|
10
|
|
|
|
|
|
|
else { |
|
11
|
0
|
0
|
|
|
|
|
print $prompt . ($def ? "[$def] " : ""); |
|
12
|
0
|
|
|
|
|
|
chomp(my $ans = ); |
|
13
|
0
|
0
|
|
|
|
|
return $ans ? $ans : $def; |
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
} |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _read_passphrase { |
|
18
|
0
|
|
|
0
|
|
|
my($prompt) = @_; |
|
19
|
0
|
|
|
|
|
|
print $prompt; |
|
20
|
0
|
|
|
|
|
|
require Term::ReadKey; |
|
21
|
0
|
|
|
|
|
|
Term::ReadKey->import; |
|
22
|
0
|
|
|
|
|
|
ReadMode('noecho'); |
|
23
|
0
|
|
|
|
|
|
chomp(my $pwd = ReadLine(0)); |
|
24
|
0
|
|
|
|
|
|
ReadMode('restore'); |
|
25
|
0
|
|
|
|
|
|
print "\n"; |
|
26
|
0
|
|
|
|
|
|
$pwd; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _read_yes_or_no { |
|
30
|
0
|
|
|
0
|
|
|
my($prompt, $def) = @_; |
|
31
|
0
|
|
|
|
|
|
print $prompt, " [$def] "; |
|
32
|
0
|
|
|
|
|
|
chomp(my $ans = ); |
|
33
|
0
|
0
|
|
|
|
|
$ans = $def unless $ans; |
|
34
|
0
|
|
|
|
|
|
$ans =~ /^y/i; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |