+ fi
+} # Form compression cmd string and filename suffix
+magicInitWorkingDir() {
+ # Desc: Determine temporary working directory from defaults or user input
+ # Input: vars: OPTION_TEMPDIR, argTmpDirPriority, DIR_TMP_DEFAULT
+ # Input: vars: SCRIPT_TIME_START
+ # Output: vars: DIR_TMP
+ # Depends: processArguments(), vbm(), yell()
+ # Parse '-t' option (user-specified temporary working dir)
+ ## Set DIR_TMP_PARENT to user-specified value if specified
+ local DIR_TMP_PARENT
+
+ if [[ "$OPTION_TMPDIR" = "true" ]]; then
+ if [[ -d "$argTempDirPriority" ]]; then
+ DIR_TMP_PARENT="$argTempDirPriority";
+ else
+ yell "WARNING:Specified temporary working directory not valid:$OPTION_TMPDIR";
+ exit 1; # Exit since user requires a specific temp dir and it is not available.
+ fi;
+ else
+ ## Set DIR_TMP_PARENT to default or fallback otherwise
+ if [[ -d "$DIR_TMP_DEFAULT" ]]; then
+ DIR_TMP_PARENT="$DIR_TMP_DEFAULT";
+ elif [[ -d /tmp ]]; then
+ yell "WARNING:$DIR_TMP_DEFAULT not available. Falling back to /tmp .";
+ DIR_TMP_PARENT="/tmp";
+ else
+ yell "ERROR:No valid working directory available. Exiting.";
+ exit 1;
+ fi
+ fi;
+ ## Set DIR_TMP using DIR_TMP_PARENT and nonce (SCRIPT_TIME_START)
+ DIR_TMP="$DIR_TMP_PARENT"/"$SCRIPT_TIME_START""..bkgpslog" && vbm "DEBUG:Set DIR_TMP to:$DIR_TMP"; # Note: removed at end of main().
+} # Sets working dir
+
+main() {
+ # Process arguments
+ processArguments "$@";
+ ## Act upon arguments
+ ### Determine working directory
+ magicInitWorkingDir; # Sets DIR_TMP
+ ### Set output encryption and compression option strings
+ #### React to "-r" ("encryption recipients") option
+ magicParseRecipientArgs; # Updates recPubKeysValid, CMD_ENCRYPT[_SUFFIX]
+ #### React to "-c" ("compression") option
+ magicParseCompressionArg; # Updates CMD_COMPRESS[_SUFFIX]
+ #### React to "-R" ("recipient directory") option
+ magicParseRecipientDir; # Updates recPubKeysValid