Improved version parsing. Fix bug on MacOS (thanks @ErebusBat)
Diff
1diff --git a/duplicity-backup.sh b/duplicity-backup.sh
2index 255283ce06c02d8cb6a26d3737c461490881a566..739fab3001802af4dbd2a533c3997db1bdbf4add 100755
3--- a/duplicity-backup.sh
4+++ b/duplicity-backup.sh
5@@ -126,12 +126,22 @@ version_compare() {
6 fi
7 }
8 9+# set a flag if duplicity's version is lower than 0.7, for usage later in the script
10 version_compare "${DUPLICITY_VERSION}" 0.7
11 case $? in 2) LT07=1;; *) LT07=0;; esac
1213-# Read the version string from the file VERSION
14-DBSH_DIRPATH=$(dirname "$(readlink -f "$0")")
15-DBSH_VERSION=$(<"${DBSH_DIRPATH}/VERSION")
16+# Read the version string from the file named VERSION in the same directory as the script.
17+if [[ "$(uname)" == "Darwin" ]]; then
18+ DBSH_VERPATH="$(dirname "$(readlink "$0")")/VERSION"
19+else
20+ DBSH_VERPATH="$(dirname "$(readlink -f "$0")")/VERSION"
21+fi
22+
23+if [ -r "${DBSH_VERPATH}" ]; then
24+ DBSH_VERSION=$(<"${DBSH_VERPATH}")
25+else
26+ DBSH_VERSION=unknown
27+fi
2829 version(){
30 echo "duplicity-backup.sh ${DBSH_VERSION}"