X-Git-Url: http://git.jankratochvil.net/?p=PerlMail.git;a=blobdiff_plain;f=perlmail-submit;h=cc76cca9453db6d407c9e7ed3a5398a961c68d90;hp=4711b746d33c0084fbe36f2fcc936a0576cb0555;hb=f29d6dc23ac3e500c8afad40a165f3d45fb67998;hpb=3cbaf4bbe1fe5f3b9f520e057ad8ef7c4d92d9c3 diff --git a/perlmail-submit b/perlmail-submit index 4711b74..cc76cca 100755 --- a/perlmail-submit +++ b/perlmail-submit @@ -230,16 +230,32 @@ my($keyword,$interval)=@_; } } +my $optwrap_err; +sub optwrap +{ +my($func,@args)=@_; + + # Prevent successful return due to --forkoff in the case of failed --store when using: + # perlmail-submit --store --forkoff --submit + if (!eval { &{$func}(@args); 1; }) { + $optwrap_err||=$@||$!; + die "!FINISH"; + die "NOTREACHED"; + } +} $Getopt::Long::ignorecase=0; -die if !GetOptions( - "initdb" ,\&initdb, - "store" ,\&store, - "forkoff",\&forkoff, - "submit" ,\&submit, - "pending",\&pending, - "dump" ,\&dump, - "clean:s",\&clean, +# &GetOptions will return success due to: die "!FINISH" +# but our error detection is done by $optwrap_err. +GetOptions( + "initdb" ,sub { optwrap \&initdb,@_; }, + "store" ,sub { optwrap \&store,@_; }, + "forkoff",sub { optwrap \&forkoff,@_; }, + "submit" ,sub { optwrap \&submit,@_; }, + "pending",sub { optwrap \&pending,@_; }, + "dump" ,sub { optwrap \&dump,@_; }, + "clean:s",sub { optwrap \&clean,@_; }, "V|version",sub { print "perlmail-submit: $VERSION\n"; exit 0; }, ); +die $optwrap_err if defined $optwrap_err; exit 0;