ee4500d005efae5ade1eac8d91a1fcc51345aae4
- Author
- zertrin <zertrin@gmail.com>
- Committer
- zertrin <zertrin@gmail.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/duplicity-backup.sh b/duplicity-backup.sh
2index bd841664ef76d2dcd1cd52c041b04d1cc1708993..6690c18b74c2e26e067e7c761864084df6eec7bc 100755
3--- a/duplicity-backup.sh
4+++ b/duplicity-backup.sh
5@@ -102,7 +102,7 @@ echo "USAGE:
6 USAGE=1
7 }
8
9-DUPLICITY="$(which duplicity)"
10+DUPLICITY="$(command -v duplicity)"
11
12 if [ ! -x "${DUPLICITY}" ]; then
13 echo "ERROR: duplicity not installed, that's gotta happen first!" >&2
14@@ -114,6 +114,7 @@ DUPLICITY_VERSION=${DUPLICITY_VERSION//[^0-9\.]/}
15
16 version_compare() {
17 if [[ $1 =~ ^([0-9]+\.?)+$ && $2 =~ ^([0-9]+\.?)+$ ]]; then
18+ # shellcheck disable=SC2206
19 local l=(${1//./ }) r=(${2//./ }) s=${#l[@]}; [[ ${#r[@]} -gt ${#l[@]} ]] && s=${#r[@]}
20
21 for i in $(seq 0 $((s - 1))); do
22@@ -151,7 +152,7 @@ while getopts ":c:t:bfvelsqndhV-:" opt; do
23 restore)
24 COMMAND=${OPTARG}
25 # We try to find the optional value [restore dest]
26- if [ ! -z "${!OPTIND:0:1}" ] && [ ! "${!OPTIND:0:1}" = "-" ]; then
27+ if [ -n "${!OPTIND:0:1}" ] && [ ! "${!OPTIND:0:1}" = "-" ]; then
28 RESTORE_DEST=${!OPTIND}
29 OPTIND=$(( OPTIND + 1 )) # we found it, move forward in arg parsing
30 fi
31@@ -161,28 +162,28 @@ while getopts ":c:t:bfvelsqndhV-:" opt; do
32 restore-file|restore-dir)
33 COMMAND=${OPTARG}
34 # We try to find the first optional value [file to restore]
35- if [ ! -z "${!OPTIND:0:1}" ] && [ ! "${!OPTIND:0:1}" = "-" ]; then
36+ if [ -n "${!OPTIND:0:1}" ] && [ ! "${!OPTIND:0:1}" = "-" ]; then
37 FILE_TO_RESTORE=${!OPTIND}
38 OPTIND=$(( OPTIND + 1 )) # we found it, move forward in arg parsing
39 else
40 continue # no value for the restore-file option, skip the rest
41 fi
42 # We try to find the second optional value [restore dest]
43- if [ ! -z "${!OPTIND:0:1}" ] && [ ! "${!OPTIND:0:1}" = "-" ]; then
44+ if [ -n "${!OPTIND:0:1}" ] && [ ! "${!OPTIND:0:1}" = "-" ]; then
45 RESTORE_DEST=${!OPTIND}
46 OPTIND=$(( OPTIND + 1 )) # we found it, move forward in arg parsing
47 fi
48 ;;
49 config) # set the config file from the command line
50 # We try to find the config file
51- if [ ! -z "${!OPTIND:0:1}" ] && [ ! "${!OPTIND:0:1}" = "-" ]; then
52+ if [ -n "${!OPTIND:0:1}" ] && [ ! "${!OPTIND:0:1}" = "-" ]; then
53 CONFIG=${!OPTIND}
54 OPTIND=$(( OPTIND + 1 )) # we found it, move forward in arg parsing
55 fi
56 ;;
57 time) # set the restore time from the command line
58 # We try to find the restore time
59- if [ ! -z "${!OPTIND:0:1}" ] && [ ! "${!OPTIND:0:1}" = "-" ]; then
60+ if [ -n "${!OPTIND:0:1}" ] && [ ! "${!OPTIND:0:1}" = "-" ]; then
61 TIME=${!OPTIND}
62 OPTIND=$(( OPTIND + 1 )) # we found it, move forward in arg parsing
63 fi
64@@ -194,7 +195,7 @@ while getopts ":c:t:bfvelsqndhV-:" opt; do
65 DRY_RUN="--dry-run"
66 ;;
67 debug)
68- ECHO=$(which echo)
69+ ECHO=$(command -v echo)
70 ;;
71 help)
72 usage
73@@ -219,7 +220,7 @@ while getopts ":c:t:bfvelsqndhV-:" opt; do
74 s) COMMAND="collection-status";;
75 q) QUIET=1;;
76 n) DRY_RUN="--dry-run";; # dry run
77- d) ECHO=$(which echo);; # debug
78+ d) ECHO=$(command -v echo);; # debug
79 h)
80 usage
81 exit 0
82@@ -240,7 +241,7 @@ done
83
84 # ---------------- Read config file if specified -----------------
85
86-if [ ! -z "${CONFIG}" ] && [ -f "${CONFIG}" ];
87+if [ -n "${CONFIG}" ] && [ -f "${CONFIG}" ];
88 then
89 # shellcheck source=duplicity-backup.conf.example
90 . "${CONFIG}"
91@@ -380,7 +381,7 @@ LOCKFILE=${LOGDIR}backup.lock
92
93 if [ "${ENCRYPTION}" = "yes" ]; then
94 ENCRYPT="--gpg-options \"${GPG_OPTIONS}\""
95- if [ ! -z "${GPG_ENC_KEY}" ] && [ ! -z "${GPG_SIGN_KEY}" ]; then
96+ if [ -n "${GPG_ENC_KEY}" ] && [ -n "${GPG_SIGN_KEY}" ]; then
97 if [ "${HIDE_KEY_ID}" = "yes" ]; then
98 ENCRYPT="${ENCRYPT} --hidden-encrypt-key=${GPG_ENC_KEY}"
99 if [ "${COMMAND}" != "restore" ] && [ "${COMMAND}" != "restore-file" ] && [ "${COMMAND}" != "restore-dir" ]; then
100@@ -389,11 +390,11 @@ if [ "${ENCRYPTION}" = "yes" ]; then
101 else
102 ENCRYPT="${ENCRYPT} --encrypt-key=${GPG_ENC_KEY} --sign-key=${GPG_SIGN_KEY}"
103 fi
104- if [ ! -z "${SECRET_KEYRING}" ]; then