diff options
-rw-r--r-- | lib/Config/HAProxy.pm | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/Config/HAProxy.pm b/lib/Config/HAProxy.pm index 794a80f..44cc3fb 100644 --- a/lib/Config/HAProxy.pm +++ b/lib/Config/HAProxy.pm @@ -10,16 +10,16 @@ use Config::HAProxy::Node::Comment; use Config::HAProxy::Node::Empty; use Text::ParseWords; use File::Basename; use File::Temp qw(tempfile); use File::stat; use File::Spec; -use IPC::Cmd; +use IPC::Cmd qw(run); use Carp; -our $VERSION = '1.03'; +our $VERSION = '1.04'; my %sections = ( global => 1, defaults => 1, frontend => 1, backend => 1, @@ -228,18 +228,20 @@ sub save { return unless $self->tree;# FIXME return unless $self->tree->is_dirty; my ($fh, $tempfile) = tempfile('haproxy.XXXXXX', DIR => dirname($self->filename)); $self->write($fh, @wrargs); close($fh); - if (my $cmd = $self->lint) { - my ($ok, $err, undef, undef, $errbuf) = - IPC::Cmd->run(command => "$cmd $tempfile"); + my ($ok, $err, $full, $outbuf, $errbuf) = + run(command => "$cmd $tempfile"); unless ($ok) { - croak "Syntax check failed: $errbuf\n"; + if ($errbuf && @$errbuf) { + croak "Syntax check failed: ".join("\n", @$errbuf)."\n"; + } + croak $err; } } return 1 if $dry_run; my $sb = stat($self->filename); $self->backup; |