while grep -q "^[^ ]\\+ ${1:A} " /proc/mounts; do
	umount ${1:A} || die "$0: Failed to umount ${(qqq)1}"
done

local -a remove
[[ -e $1 ]] && remove+=( $1/*(DN) )
if (($#remove)); then
	rm -rf $remove || die "$0: Failed to clean output directory: ${(qqq)1}"
fi

mkdir -p $1 || die "$0: Failed to create output directory: ${(qqq)1}"

add_finish_hook dep_add_dir $1
# vim: fileencoding=utf8 ft=zsh noet sw=4 ts=4 sts=4