From: Eric Gillespie Date: Fri, 5 Dec 2014 22:48:19 +0000 (-0800) Subject: fix checking errors when running mhpath X-Git-Url: https://diplodocus.org/git/minc/commitdiff_plain/9296d92aad740e5025c392b9b7079480e63d97c8?hp=7019aa52cf491afad73906632f9431d740bf5275 fix checking errors when running mhpath --- diff --git a/minc b/minc index 2e93e13..cce6766 100755 --- a/minc +++ b/minc @@ -45,6 +45,7 @@ use File::FcntlLock; use File::Temp qw(tempfile); use File::stat; use Getopt::Long qw(:config gnu_getopt no_ignore_case); +use POSIX qw(WIFEXITED WEXITSTATUS WIFSIGNALED WTERMSIG); use Pod::Usage; use constant LOCK_TRIES => 60; @@ -185,8 +186,11 @@ our $folder_sorter = sub { sort_by_list(@_, @folder_sort_list) }; my $mh; -$mh = `mhpath +` or die; +$mh = `mhpath +`; $? >= 0 or die; chomp($mh); +if (!$mh) { + die('mhpath did not give MH mail path: ' . exit_msg($?)); +} $ENV{"MHCONTEXT"} = $mh . '/.minc.context'; @@ -194,6 +198,14 @@ $ENV{"MHCONTEXT"} = $mh . '/.minc.context'; ############################################################################### # Utility procedures +sub exit_msg { + my $status = shift; + WIFEXITED($status) && return 'exited with status ' . WEXITSTATUS($status); + WIFSIGNALED($status) && return 'killed with signal ' . WTERMSIG($status); + # WTF + "died ($status)"; +} + sub sort_by_list { my $a = shift; my $b = shift;