]> gitweb.fluxo.info Git - keyringer.git/commitdiff
Pipefail approach (#6)
authorSilvio Rhatto <rhatto@riseup.net>
Mon, 18 Mar 2013 21:04:38 +0000 (18:04 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Mon, 18 Mar 2013 21:04:38 +0000 (18:04 -0300)
share/keyringer/recrypt

index fc166038dec402b90f8c1d528ecb7a336420e741..695e789d5aab2d5ac2db3682d04272ff2aec6045 100755 (executable)
@@ -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