summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xsrc/backupit27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/backupit b/src/backupit
index 54c9581..ec99c32 100755
--- a/src/backupit
+++ b/src/backupit
@@ -26,9 +26,26 @@ shift $((OPTIND - 1))
TAG="${1:-default}"
ARCHIVE="::{hostname}-{user}-{now}-$TAG"
-F="$XDG_CONFIG_HOME"/backupit.txt
-if [ ! -e "$F" ]; then
- F=/etc/backup.txt
-fi
-borgy $VERBOSE_FLAGS "$ARCHIVE" $(cat "$F")
+
+xdg="${XDG_CONFIG_HOME:-$HOME/.config}"/backupit.txt
+global=/etc/backupit.txt
+f() {
+ if [ -e "$xdg" ]; then
+ printf '%s' "$xdg"
+ return
+ fi
+
+ if [ -e "$global" ]; then
+ printf '%s' "$global"
+ return
+ fi
+
+ printf 'Cannot find either\nlocal (%s) or\nglobal (%s) file.\n\n' \
+ "$xdg" "$global" >&2
+ usage >&2
+ exit 2
+}
+
+F="$(f)"
+exec borgy $VERBOSE_FLAGS "$ARCHIVE" $(cat "$F")