File: lib.sh

package info (click to toggle)
bup 0.33.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,720 kB
  • sloc: python: 15,905; sh: 5,799; ansic: 2,965; pascal: 669; makefile: 21
file content (42 lines) | stat: -rw-r--r-- 1,021 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Assumes shell is Bash, and pipefail is set.

# Assumes this is always loaded while pwd is still the source tree root
bup_dev_lib_top=$(pwd) || exit $?

bup-cfg-py() { "$bup_dev_lib_top/dev/python" "$@"; }
bup-python() { "$bup_dev_lib_top/dev/bup-python" "$@"; }

force-delete()
{
    "$bup_dev_lib_top/dev/force-delete" "$@"
}

resolve-parent()
{
    test "$#" -eq 1 || return $?
    echo "$1" | \
        bup-python \
            -c "import sys, bup.helpers; print(bup.helpers.resolve_parent(sys.stdin.readline()))" \
        || return $?
}

path-filesystems()
(
    # Return filesystem for each dir from $1 to /.
    # Perhaps for /foo/bar, "ext4\next4\nbtrfs\n".
    test "$#" -eq 1 || exit $?
    cd "$1" || exit $?
    "$bup_dev_lib_top/dev/path-fs" . || exit $?
    dir="$(pwd)" || exit $?
    while test "$dir" != /; do
        cd .. || exit $?
        dir="$(pwd)" || exit $?
        "$bup_dev_lib_top/dev/path-fs" . || exit $?
    done
    exit 0
)

escape-erx()
{
    sed 's/[][\.|$(){?+*^]/\\&/g' <<< "$*"
}