-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cleanup.sh
executable file
·55 lines (41 loc) · 1.23 KB
/
cleanup.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
#!/usr/bin/env sh
##################################
# shellcheck shell=sh enable=all #
##################################
[ -z "${SHDEBUG}" ] || set -vx
runquiet() {
"${@}" >/dev/null 2>&1
}
swd="${0%"${0##*/}"}"
if [ -n "${swd}" ]; then
runquiet cd "${swd}" || {
printf "Fatal: unable to change current working directory to %s.\n" "${swd}" >&2
exit 1
}
fi
###############################
# shellcheck source=/dev/null #
###############################
. ../src/which.extended.sh
scriptDir="$(pwd -P 2>/dev/null)"
[ -x "${scriptDir}/${0##*/}" ] || {
printf "Fatal: unable to locate %s folder properly.\n" dev >&2
exit 1
}
#############################
# shellcheck disable=SC2230 #
#############################
which -s rm || {
printf "This script requires %s command and/or builtin to clean %s.\n" rm "${scriptDir}" >&2
printf "Please install %s command and relaunch.\n" rm >&2
exit 1
}
if test -d bin -o -d tests/shellspec; then
for folder in bin tests/shellspec; do
[ -d "${scriptDir}/${folder}" ] && runquiet rm -rf "${scriptDir}/${folder}"
done
printf "%s has been cleaned.\n" "${scriptDir}" >&2
else
printf "Nothing to clean at %s.\n" "${scriptDir}" >&2
exit 1
fi