Subject: | [PATCH] Allow empty user/pass with DBI_USER/DBI_PASS set |
Attached.
Subject: | 0001-allow-the-use-of-empty-user-password-with-DBI_USER-D.patch |
From 9f9d94ce269e3010c448a86da470334ccba25956 Mon Sep 17 00:00:00 2001
From: Rafael Kitover <rkitover@cpan.org>
Date: Sat, 29 Jan 2011 20:59:12 -0500
Subject: [PATCH] allow the use of empty user/password with DBI_USER/DBI_PASS set
---
lib/DBI/Format.pm | 2 +-
lib/DBI/Shell.pm | 9 ++++++---
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/lib/DBI/Format.pm b/lib/DBI/Format.pm
index 49cd7dd..5fcac76 100755
--- a/lib/DBI/Format.pm
+++ b/lib/DBI/Format.pm
@@ -374,7 +374,7 @@ sub header {
sub row {
my($self, $rowref) = @_;
- local( $^W = 0 );
+ local $^W = 0;
my @row = @$rowref;
my $fh = $self->{'fh'};
print $fh (join($self->{sep}, @row), "\n");
diff --git a/lib/DBI/Shell.pm b/lib/DBI/Shell.pm
index 03dd958..da9aa55 100755
--- a/lib/DBI/Shell.pm
+++ b/lib/DBI/Shell.pm
@@ -467,9 +467,12 @@ sub new {
# This may be obsolete since it is run again in DBI::Shell::new.
$sh->do_format($sh->{format});
- $sh->{data_source} = shift(@args) || $ENV{DBI_DSN} || '';
- $sh->{user} = shift(@args) || $ENV{DBI_USER} || '';
- $sh->{password} = shift(@args) || $ENV{DBI_PASS} || undef;
+ $sh->{data_source} = shift(@args) || $ENV{DBI_DSN} || '';
+
+ my $user = shift(@args);
+ $sh->{user} = defined $user ? $user : $ENV{DBI_USER} || '';
+ my $password = shift(@args);
+ $sh->{password} = defined $password ? $password : $ENV{DBI_PASS} || undef;
$sh->{chistory} = []; # command history
$sh->{rhistory} = []; # result history
--
1.7.3.3