0

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?

  • TAROPTS can't deal with spaces (or things with filename globbing characters), it should be an array, and should be used quoted.. See, e.g. https://unix.stackexchange.com/questions/444946 – Kusalananda Jan 30 '22 at 21:33
  • @they Looks like arrays are the way to go! thanks – preferred_anon Jan 30 '22 at 22:45

0 Answers0