From 6bce7517ee43b52e0a23c74dec8f5d0bcb7d0668 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 16 Jul 2016 23:35:21 +0100 Subject: Subprocess error handling: Fix when divert check fails If the remote command failed, do not try to match the undef value against the various regexps. --- dgit | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dgit b/dgit index f60180c..54a1c15 100755 --- a/dgit +++ b/dgit @@ -1160,7 +1160,7 @@ sub check_for_git () { " set -e; cd ".access_cfg('git-path').";". " if test -d $package.git; then echo 1; else echo 0; fi"); my $r= cmdoutput @cmd; - if ($r =~ m/^divert (\w+)$/) { + if (defined $r and $r =~ m/^divert (\w+)$/) { my $divert=$1; my ($usedistro,) = access_distros(); # NB that if we are pushing, $usedistro will be $distro/push @@ -1169,7 +1169,7 @@ sub check_for_git () { progress "diverting to $divert (using config for $instead_distro)"; return check_for_git(); } - failedcmd @cmd unless $r =~ m/^[01]$/; + failedcmd @cmd unless defined $r and $r =~ m/^[01]$/; return $r+0; } elsif ($how eq 'url') { my $prefix = access_cfg('git-check-url','git-url'); -- cgit v1.2.3