more refactoring

This commit is contained in:
James Barnett 2017-02-14 11:13:36 -06:00
parent 1969e5bd15
commit ea299e2b8a
No known key found for this signature in database
GPG key ID: E4B5E45AA3B8C5C3

View file

@ -26,8 +26,8 @@ declare -r name="snap-pac"
declare PACMAN_ABORT_ON_FAIL="no" declare PACMAN_ABORT_ON_FAIL="no"
out() { printf "$1 $2\n" "${@:3}"; } out() { printf "$1 $2\n" "${@:3}"; }
error() { out "\033[00;31m==> ERROR:\033[00m" "$@"; } >&2 error() { out "\033[00;31m==> ERROR:\033[00m" "$@"; } >&2
warning() { out "\033[00;33m==> WARNING:\033[00m" "$@"; } >&2 warning() { out "\033[00;33m==> WARNING:\033[00m" "$@"; } >&2
die() { die() {
error "$@" error "$@"
[[ $PACMAN_ABORT_ON_FAIL == "yes" ]] && exit 1 [[ $PACMAN_ABORT_ON_FAIL == "yes" ]] && exit 1
@ -87,18 +87,14 @@ for CONFIG in $SNAPPER_CONFIGS; do
x=$((x+1)) x=$((x+1))
printf "==> %s " "$CONFIG" if [[ "$pre_or_post" == "pre" ]]; then
case "$pre_or_post" in printf "==> %s $($snapper_cmd "$(truncate_description $PACMAN_PRE_DESCRIPTION)" | tee "$prefile")\n" "$CONFIG"
pre) printf "$($snapper_cmd "$(truncate_description $PACMAN_PRE_DESCRIPTION)" | tee "$prefile")\n" ;; elif [[ -f $prefile && "$pre_or_post" == "post" ]]; then
post) printf "==> %s $($snapper_cmd "$(truncate_description $PACMAN_POST_DESCRIPTION)" --pre-number "$(< "$prefile")")\n" "$CONFIG"
if [[ -f $prefile ]]; then rm -f "$prefile"
printf "$($snapper_cmd "$(truncate_description $PACMAN_POST_DESCRIPTION)" --pre-number "$(< "$prefile")")\n" elif [[ ! -f $prefile && "$pre_or_post" == "post" ]]; then
rm -f "$prefile" warning "%s does not exist, so no post snapshot for %s will be taken. If you are initially installing $name, this is normal." "$prefile" "$CONFIG"
else fi
warning "%s does not exist, so no post snapshot for %s will be taken. If you are initially installing $name, this is normal." "$prefile" "$CONFIG"
fi
;;
esac
done done