aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2013-03-18 18:04:38 -0300
committerSilvio Rhatto <rhatto@riseup.net>2013-03-18 18:04:38 -0300
commit7423fcdcbbe586d2e6b6b675dbaff8a7a7bf7d0f (patch)
tree2b9a67856d7dcac03bb0891cde8a2565f485ddb9
parent4153129f3ae06a7dca7085e05e278232bbb81d32 (diff)
downloadkeyringer-7423fcdcbbe586d2e6b6b675dbaff8a7a7bf7d0f.tar.gz
keyringer-7423fcdcbbe586d2e6b6b675dbaff8a7a7bf7d0f.tar.bz2
Pipefail approach (#6)
-rwxr-xr-xshare/keyringer/recrypt14
1 files 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