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