diff options
author | Andinus <andinus@nand.sh> | 2020-08-27 14:50:24 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2020-08-27 14:50:24 +0530 |
commit | 61e44ee71deaa01a23866cf069df4ceaa0bf4446 (patch) | |
tree | f5ff95e127b9a3b1a6f5cddbd9a1038e29e4d7c2 | |
parent | 6a3cb1464f3824cc0a8e26e5a0c509b5c8e08547 (diff) | |
download | leo-61e44ee71deaa01a23866cf069df4ceaa0bf4446.tar.gz |
Fix deletion, check $? for gpg2
Maybe I should delete the tar file by default & add a `nodelete' option.
-rwxr-xr-x | leo.pl | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/leo.pl b/leo.pl index d33604e..9d14e9d 100755 --- a/leo.pl +++ b/leo.pl @@ -82,12 +82,17 @@ sub encrypt_sign() { push @options, "--verbose" if $options{verbose}; say "\nEncrypt/Sign: $file"; - run3 ["gpg2", "--yes", "-o", "$file.gpg", @options, $file]; warn "[WARN] $file.gpg exists, might overwrite.\n" if -e "$file.gpg"; - say "\nOutput: $file.gpg"; + + run3 ["gpg2", "--yes", "-o", "$file.gpg", @options, $file]; + + $? # We assume non-zero is an error. + ? die "Encrypt/Sign failed :: $?\n" + : say "\nOutput: $file.gpg"; unlink $file and say "$file deleted." - or warn "[WARN] Could not delete $file: $!\n"; + or warn "[WARN] Could not delete $file: $!\n" + if $options{delete}; } sub HelpMessage { |