Skip to content

Commit

Permalink
Use portable /dev/null from File::Spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Apr 2, 2011
1 parent 32b1eb2 commit 6add618
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions mysqltuner.pl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
use strict;
use warnings;
use diagnostics;
use File::Spec;
use Getopt::Long;

# Set up a few variables for use in the script
Expand Down Expand Up @@ -116,6 +117,8 @@ sub usage {
exit;
}

my $devnull = File::Spec->devnull();

# Setting up the colors for the print styles
my $good = ($opt{nocolor} == 0)? "[\e[0;32mOK\e[0m]" : "[OK]" ;
my $bad = ($opt{nocolor} == 0)? "[\e[0;31m!!\e[0m]" : "[!!]" ;
Expand Down Expand Up @@ -308,9 +311,9 @@ sub mysql_setup {
print STDERR "Please enter your MySQL administrative login: ";
my $name = <>;
print STDERR "Please enter your MySQL administrative password: ";
system("stty -echo >/dev/null 2>&1");
system("stty -echo >$devnull 2>&1");
my $password = <>;
system("stty echo >/dev/null 2>&1");
system("stty echo >$devnull 2>&1");
chomp($password);
chomp($name);
$mysqllogin = "-u $name";
Expand Down Expand Up @@ -361,7 +364,7 @@ sub get_all_vars {
# have_* for engines is deprecated and will be removed in MySQL 5.6;
# check SHOW ENGINES and set corresponding old style variables.
# Also works around MySQL bug #59393 wrt. skip-innodb
my @mysqlenginelist = `mysql $mysqllogin -Bse "SHOW ENGINES;" 2>/dev/null`;
my @mysqlenginelist = `mysql $mysqllogin -Bse "SHOW ENGINES;" 2>$devnull`;
foreach my $line (@mysqlenginelist) {
if ($line =~ /^([a-zA-Z_]+)\s+(\S+)/) {
my $engine = lc($1);
Expand Down Expand Up @@ -412,10 +415,10 @@ sub validate_tuner_version {
my $update;
my $url = "http://mysqltuner.com/versioncheck.php?v=$tunerversion";
if (-e "/usr/bin/curl") {
$update = `/usr/bin/curl --connect-timeout 5 '$url' 2>/dev/null`;
$update = `/usr/bin/curl --connect-timeout 5 '$url' 2>$devnull`;
chomp($update);
} elsif (-e "/usr/bin/wget") {
$update = `/usr/bin/wget -e timestamping=off -T 5 -O - '$url' 2>/dev/null`;
$update = `/usr/bin/wget -e timestamping=off -T 5 -O - '$url' 2>$devnull`;
chomp($update);
}
if ($update eq 1) {
Expand Down

0 comments on commit 6add618

Please sign in to comment.