Consider the following script: https://github.com/danielittlewood0/rbackup/blob/master/rbackup-archive.bash
I basically want to optionally allow the user to tar-and-encrypt, or to just tar. The tar command is almost the same in the two cases - the shared options are
TAROPTS="--remove-files --create --check-links --gzip --directory=$BACKUP_DEST/snapshots"
I am worried about the case where the variable $BACKUP_DEST contains spaces. I tried including escaped quotes in that variable, i.e.
TAROPTS="... --directory=\"$BACKUP_DEST/snapshots\""
but that resulted in a filepath with actual quotes in it (which the command failed to find).
Does the options I tried "just work", or is there another way?