forked from bats-core/bats-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.sh
executable file
·63 lines (51 loc) · 1.2 KB
/
uninstall.sh
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env bash
set -e
BATS_ROOT="${0%/*}"
PREFIX="${1%/}"
if [[ -z "$PREFIX" ]]; then
printf '%s\n' \
"usage: $0 <prefix> [base_libdir]" \
" e.g. $0 /usr/local" \
" $0 /usr/local lib64" >&2
exit 1
fi
if [[ ! -d "$PREFIX" ]]; then
printf "No valid installation in directory %s.\n" "$PREFIX"
exit 2
fi
if [ -e "$PREFIX/bin/bats" ]; then
LIBDIR=$(grep -e '^BATS_BASE_LIBDIR=' "$PREFIX/bin/bats")
eval "$LIBDIR"
fi
LIBDIR="${BATS_BASE_LIBDIR:-lib}"
remove_file() { # <file>
echo "Removing $1"
rm -f "$1"
}
remove_directory() { # <directory>
local directory=$1
if [[ -d "$directory" ]]; then
echo "Removing $directory"
rmdir "$directory"
fi
}
d="$PREFIX/bin"
for elt in "$BATS_ROOT/bin"/*; do
elt=${elt##*/}
remove_file "$d/$elt"
done
d="$PREFIX/libexec/bats-core"
for elt in "$BATS_ROOT/libexec/bats-core"/*; do
elt=${elt##*/}
remove_file "$d/$elt"
done
remove_directory "$d"
d="$PREFIX/${LIBDIR}/bats-core"
for elt in "$BATS_ROOT/lib/bats-core"/*; do
elt=${elt##*/}
remove_file "$d/$elt"
done
remove_directory "$d"
remove_file "$PREFIX"/share/man/man1/bats.1
remove_file "$PREFIX"/share/man/man7/bats.7
echo "Uninstalled Bats from $PREFIX/bin/bats"