declare -Ag fileRollCall # Associative array for storing file status
declare -Ag dirRollCall # Associative array for storing dir status
declare -a recPubKeys # for processArguments function
+declare recipients # for main function
#===BEGIN Declare local script functions===
checkapp() {
-o | --output) if [ -d "$2" ]; then DIROUT="$2"; vbm "DEBUG:DIROUT:$DIROUT"; shift; fi ;; # Define output directory.
-e | --encrypt) OPTION_ENCRYPT="true"; vbm "DEBUG:Encrypted output mode enabled.";;
-r | --recipient) # Add 'age' recipient via public key string
- recPubKeys+=("$2"); shift;;
+ recPubKeys+=("$2"); vbm "pubkey added:""$2"; shift;;
*) echoerr "ERROR: Unrecognized argument."; exit 1;; # Handle unrecognized options.
esac
shift
for pubkey in "${recPubKeys[@]}"; do # Validate recipient pubkey strings by forming test message
vbm "DEBUG:Testing pubkey string:$pubkey"
if ! echo "butts" | age -a -r "$pubkey" 1>/dev/null; then
- yell "ERROR:Exit code ""$?"". Invalid recipient pubkey string. Exiting."; exit 1; fi
+ yell "ERROR:Exit code ""$?"". Invalid recipient pubkey string. Exiting."; exit 1;
+ else
+ # Form age recipient string
+ recipients="$recipients""-r $pubkey ";
+ vbm "Added pubkey:""$pubkey";
+ vbm "DEBUG:recipients:""$recipients";
+ fi
done
+ vbm "DEBUG:Finished processing recPubKeys array";
else
yell "ERROR:Encryption enabled but \"age\" not found. Exiting."; exit 1;
fi