# Assumes shell is Bash, and pipefail is set.
+bup_t_lib_script_home=$(cd "$(dirname $0)" && pwd) || exit $?
+
+bup-python()
+{
+ "$bup_t_lib_script_home/../cmd/bup-python" "$@"
+}
+
force-delete()
{
- local rc=0
- # Try *hard* to delete $@. Among other things, some systems have
- # r-xr-xr-x for root and other system dirs.
- rm -rf "$@" # Maybe we'll get lucky.
- for f in "$@"; do
- test -e "$f" || continue
- if test "$(type -p setfacl)"; then
- setfacl -Rb "$f"
- fi
- if test "$(type -p chattr)"; then
- chattr -R -aisu "$f"
- fi
- chmod -R u+rwX "$f"
- rm -r "$f"
- if test -e "$f"; then
- rc=1
- find "$f" -ls
- lsattr -aR "$f"
- getfacl -R "$f"
- fi
- done
- return $rc
+ "$bup_t_lib_script_home/force-delete" "$@"
}
-realpath()
+resolve-parent()
{
test "$#" -eq 1 || return $?
- local script_home=$(cd "$(dirname $0)" && pwd)
echo "$1" | \
- PYTHONPATH="${script_home}/../lib" python -c \
- "import sys, bup.helpers; print bup.helpers.realpath(sys.stdin.readline())" \
+ PYTHONPATH="$bup_t_lib_script_home/../lib" bup-python -c \
+ "import sys, bup.helpers; print bup.helpers.resolve_parent(sys.stdin.readline())" \
|| return $?
}
current-filesystem()
{
- df -T . | awk 'END{print $2}'
+ local kernel="$(uname -s)" || return $?
+ case "$kernel" in
+ NetBSD)
+ df -G . | sed -En 's/.* ([^ ]*) fstype.*/\1/p'
+ ;;
+ SunOS)
+ df -g . | sed -En 's/.* ([^ ]*) fstype.*/\1/p'
+ ;;
+ *)
+ df -T . | awk 'END{print $2}'
+ esac
}
path-filesystems()
done
exit 0
)
+
+escape-erx()
+{
+ sed 's/[][\.|$(){?+*^]/\\&/g' <<< "$*"
+}