[check_postgres] [commit] Finally fix the space-in-directory issues - Jeff Boes.

check_postgres at bucardo.org check_postgres at bucardo.org
Fri Apr 10 16:31:17 UTC 2009


Committed by Greg Sabino Mullane <greg at endpoint.com>

Finally fix the space-in-directory issues - Jeff Boes.

---
 check_postgres.pl |    2 +-
 t/CP_Testing.pm   |    8 +++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/check_postgres.pl b/check_postgres.pl
index b09d324..c46f2d3 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -1409,7 +1409,7 @@ sub run_command {
 			}
 			if (defined $opt{$v}->[$gbin]) {
 				my $new = $opt{$v}->[$gbin];
-				$new =~ s/\s+//g unless $vname eq 'dbservice';
+				$new =~ s/\s+//g unless $vname eq 'dbservice' or $vname eq 'host';
 				## Set this as the new default
 				$conn->{$vname} = [split /,/ => $new];
 				$foundgroup = 1;
diff --git a/t/CP_Testing.pm b/t/CP_Testing.pm
index 6600437..67ea10e 100644
--- a/t/CP_Testing.pm
+++ b/t/CP_Testing.pm
@@ -126,7 +126,11 @@ sub test_database_handle {
 	} ## end of needs startup
 
 	my $here = cwd();
-	my $dsn = qq{dbi:Pg:host=$here/$dbdir/data/socket;dbname=postgres};
+	my $dbhost = $self->{dbhost} = "$here/$dbdir/data/socket";
+	$dbhost =~ s/^ /\\ /;
+	$dbhost =~ s/([^\\]) /$1\\ /g;
+	$self->{dbname} = 'postgres';
+	my $dsn = qq{dbi:Pg:host=$dbhost;dbname=$self->{dbname}};
 	my @superdsn = ($dsn, '', '', {AutoCommit=>0,RaiseError=>1,PrintError=>0});
 	my $dbh = DBI->connect(@superdsn);
 	$dbh->ping() or die qq{Failed to ping!\n};
@@ -143,8 +147,6 @@ sub test_database_handle {
 	$dbh->{AutoCommit} = 0;
 	$dbh->{RaiseError} = 1;
 
-	$self->{dbhost} = "$here/$dbdir/data/socket";
-	$self->{dbname} = 'postgres';
 	$self->{dbh} = $dbh;
 	$self->{dsn} = $dsn;
 	$self->{superdsn} = \@superdsn;
-- 
1.6.0.5



More information about the Check_postgres mailing list