X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=t%2Flib.sh;h=4d67341e5330c7e725ebb50915a7128a5e54c173;hb=bf67f94dd4f4096de4eee07a7dc377d6c889a016;hp=93b2e598bb50b7ad62c90905c1e48f1c88d42bbf;hpb=4ff4df24744887b1a26b2d21a256f1823f3d21cd;p=bup.git diff --git a/t/lib.sh b/t/lib.sh index 93b2e59..4d67341 100644 --- a/t/lib.sh +++ b/t/lib.sh @@ -1,39 +1,23 @@ # Assumes shell is Bash, and pipefail is set. -bup_t_lib_script_home=$(cd "$(dirname $0)" && pwd) +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 $? echo "$1" | \ - PYTHONPATH="$bup_t_lib_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 $? } @@ -67,3 +51,8 @@ path-filesystems() done exit 0 ) + +escape-erx() +{ + sed 's/[][\.|$(){?+*^]/\\&/g' <<< "$*" +}