chore: improve clean.sh

This commit is contained in:
Gregor Kleen 2019-09-18 11:45:20 +02:00
parent 014a17a3be
commit 459a773148

View File

@ -10,6 +10,8 @@ case $1 in
;;
*)
target=".stack-work-${1}"
shift
if [[ ! -d "${target}" ]]; then
printf "%s does not exist or is no directory\n" "${target}" >&2
exit 1
@ -20,7 +22,11 @@ case $1 in
fi
move-back() {
mv -v .stack-work "${target}"
if [[ -d .stack-work ]]; then
mv -v .stack-work "${target}"
else
mkdir -v "${target}"
fi
[[ -d .stack-work-clean ]] && mv -v .stack-work-clean .stack-work
}
@ -28,6 +34,9 @@ case $1 in
mv -v "${target}" .stack-work
trap move-back EXIT
stack clean
(
set -ex
stack clean $@
)
;;
esac