6377ad5281f31b71f26f8205130ac552a6d2cbef

Author
Andrea Richiardi <a.richiardi.work@gmail.com>
Committer
Andrea Richiardi <a.richiardi.work@gmail.com>
Date

Message

Use regex for trimming file:// destinations

A problem with cut was causing:

  $ DEST="file:///media/user/data"
  $ TMPDEST=$(echo "${DEST}" | cut -c 6-)
  $ echo $TMPDEST
  ///media/user/data

The fix uses a regex instead so that we trim away things correctly. It also seems somewhat more
readable.

Diff

 1diff --git a/duplicity-backup.sh b/duplicity-backup.sh
 2index 57e52a45d8862dfd72d9d4c08357b73818573cb1..c3c45d2886c9faf6a4d9ffd2f8b55d73973f9eb8 100755
 3--- a/duplicity-backup.sh
 4+++ b/duplicity-backup.sh
 5@@ -650,7 +650,7 @@ get_remote_file_size()
 6     ;;
 7     "fi")
 8       FRIENDLY_TYPE_NAME="File"
 9-      TMPDEST=$(echo "${DEST}" | cut -c 6-)
10+      TMPDEST="${DEST#file://*}"
11       SIZE=$(du -hs "${TMPDEST}" | awk '{print $1}')
12     ;;
13     "gs")