]> gitweb.fluxo.info Git - borger.git/commitdiff
Ensure BORG_PASSPHRASES is a global variable
authorSilvio Rhatto <rhatto@riseup.net>
Thu, 8 Aug 2019 21:52:31 +0000 (18:52 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Thu, 8 Aug 2019 21:52:31 +0000 (18:52 -0300)
borger

diff --git a/borger b/borger
index 531e32aa44853b14ef5628236e6cc4c4eafb6ba8..5c966b4ee4ebddbb27a5ede285fef74f1e94d443 100755 (executable)
--- a/borger
+++ b/borger
@@ -268,16 +268,6 @@ function borger_single {
 function borger_multiple {
   info "Multiple destination \"$DESTINATION\" found. Processing each subconfig..."
 
-  # Needs bash 4
-  # https://stackoverflow.com/questions/1494178/how-to-define-hash-tables-in-bash
-  if echo $BASH_VERSION | grep -q "^3"; then
-    fatal "$BASENAME requires bash 4 or newer."
-  fi
-
-  # Passphrase array
-  declare -A BORG_PASSPHRASES
-  export BORG_PASSCOMMAND=""
-
   # Evaluate each config
   for config in `ls $CONFIG`; do
     # Include BORG_PASSPHRASE config for each destination in an array
@@ -297,6 +287,7 @@ function borger_multiple {
   # Serial approach
   for config in `ls $CONFIG`; do
     info "Calling borger for $DESTINATION/$config..."
+    export BORG_PASSCOMMAND=""
     export BORG_PASSPHRASE="${BORG_PASSPHRASES[$config]}"
     $FULLNAME $DESTINATION/$config 2>&1 | sed -e "s/^\[borger\]/[borger] [$config]/" -e "s/^\([^\[]\)/[borger] [$config] \1/"
   done
@@ -353,6 +344,15 @@ function borger_continuous {
   done
 }
 
+# Strong requirement: bash 4
+# https://stackoverflow.com/questions/1494178/how-to-define-hash-tables-in-bash
+if echo $BASH_VERSION | grep -q "^3"; then
+  fatal "$BASENAME requires bash 4 or newer."
+fi
+
+# Declare global passphrase array
+declare -A BORG_PASSPHRASES
+
 # Setup
 borger_setup