From 7423fcdcbbe586d2e6b6b675dbaff8a7a7bf7d0f Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Mon, 18 Mar 2013 18:04:38 -0300 Subject: Pipefail approach (#6) --- share/keyringer/recrypt | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/share/keyringer/recrypt b/share/keyringer/recrypt index fc16603..695e789 100755 --- a/share/keyringer/recrypt +++ b/share/keyringer/recrypt @@ -14,18 +14,12 @@ function keyringer_recrypt { # Set recipients file keyringer_set_recipients "$FILE" - # Test decryption - $GPG --use-agent -d "$KEYDIR/$FILE" > /dev/null - - err="$?" - - if [ "$err" != "0" ]; then - echo "$BASENAME: decryption failed. Can't recrypt." - exit "$err" - fi + # Set pipefail so we can detect decryption failures + set -o pipefail # Recrypt - $GPG --use-agent -d "$KEYDIR/$FILE" | $GPG --use-agent --armor -e -s $(keyringer_recipients "$RECIPIENTS_FILE") > "$KEYDIR/$FILE" + $GPG --use-agent -d "$KEYDIR/$FILE" | \ + $GPG --use-agent --armor -e -s $(keyringer_recipients "$RECIPIENTS_FILE") > "$KEYDIR/$FILE" if [ "$?" != "0" ]; then exit 1 -- cgit v1.2.3