mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-12-20 02:20:04 +08:00
Merge ubuntu-12-64-issues
This commit is contained in:
@@ -15,8 +15,14 @@
|
||||
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
# Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
# ###########################################################################
|
||||
# ReadKeyMini
|
||||
# ReadKeyMini package
|
||||
# ###########################################################################
|
||||
|
||||
# Package: ReadKeyMini
|
||||
# ReadKeyMini is a wrapper around Term::ReadKey. If that's available,
|
||||
# we use ReadMode and GetTerminalSize from there. Otherwise, we use homebrewn
|
||||
# definitions.
|
||||
|
||||
BEGIN {
|
||||
|
||||
package ReadKeyMini;
|
||||
@@ -29,11 +35,6 @@ package ReadKeyMini;
|
||||
# would solve the issue.
|
||||
BEGIN { $INC{"ReadKeyMini.pm"} ||= 1 }
|
||||
|
||||
# Package: ReadKeyMini
|
||||
# ReadKeyMini is a wrapper around Term::ReadKey. If that's available,
|
||||
# we use ReadMode and GetTerminalSize from there. Otherwise, we use homebrewn
|
||||
# definitions.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
use English qw(-no_match_vars);
|
||||
@@ -72,7 +73,7 @@ my %modes = (
|
||||
my $flags;
|
||||
unless ( $PerconaTest::DONT_RESTORE_STDIN ) {
|
||||
$flags = fcntl(STDIN, F_GETFL, 0)
|
||||
or die "can't fcntl F_GETFL: $!";
|
||||
or warn "can't fcntl F_GETFL: $!";
|
||||
}
|
||||
my $term = POSIX::Termios->new();
|
||||
$term->getattr($fd_stdin);
|
||||
@@ -106,7 +107,7 @@ my %modes = (
|
||||
$term->setattr( $fd_stdin, TCSANOW );
|
||||
unless ( $PerconaTest::DONT_RESTORE_STDIN ) {
|
||||
fcntl(STDIN, F_SETFL, $flags)
|
||||
or die "can't fcntl F_SETFL: $!";
|
||||
or warn "can't fcntl F_SETFL: $!";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,16 +169,18 @@ sub _GetTerminalSize {
|
||||
}
|
||||
}
|
||||
|
||||
eval {
|
||||
if ( $rows = `tput lines` ) {
|
||||
chomp($rows);
|
||||
chomp($cols = `tput cols`);
|
||||
}
|
||||
elsif ( my $stty = `stty -a` ) {
|
||||
($rows, $cols) = $stty =~ /([0-9]+) rows; ([0-9]+) columns;/;
|
||||
}
|
||||
};
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
if ( $rows = `tput lines 2>/dev/null` ) {
|
||||
chomp($rows);
|
||||
chomp($cols = `tput cols`);
|
||||
}
|
||||
elsif ( my $stty = `stty -a 2>/dev/null` ) {
|
||||
($rows, $cols) = $stty =~ /([0-9]+) rows; ([0-9]+) columns;/;
|
||||
}
|
||||
else {
|
||||
($cols, $rows) = @ENV{qw( COLUMNS LINES )};
|
||||
$cols ||= 80;
|
||||
$rows ||= 24;
|
||||
}
|
||||
|
||||
return ( $cols, $rows );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user