From 54df716ec12474e4ecac4acbc8d9e4cc52d132db Mon Sep 17 00:00:00 2001 From: James Barnett Date: Fri, 3 Feb 2017 09:36:57 -0600 Subject: [PATCH] make if logic clearer --- scripts/snap-pac | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/scripts/snap-pac b/scripts/snap-pac index 136db60..d2f4283 100755 --- a/scripts/snap-pac +++ b/scripts/snap-pac @@ -137,16 +137,21 @@ for CONFIG in $SNAPPER_CONFIGS; do if [[ "$pre_or_post" == "pre" ]]; then $snapper_cmd --description "$PACMAN_PRE_DESCRIPTION" --print-number > "$prefile" - printf "%s %s\n" "$(< "$prefile")" "$checkmark" - elif [[ "$pre_or_post" == "rem" && -f "$prefile" ]]; then + printf " %s %s %s\n" "$CONFIG" "$(< "$prefile")" "$checkmark" + elif [[ "$pre_or_post" == "rem" ]]; then printf "N/A\n" - rm "$prefile" - elif [[ -f $prefile ]]; then - postnum=$($snapper_cmd --description "$PACMAN_POST_DESCRIPTION" --print-number --pre-number "$(< "$prefile")") - printf "%s %s\n" "$postnum" "$checkmark" - rm "$prefile" - else - printf "%b %s does not exist, so no post snapshot will be taken. If you are initially installing snap-pac, this is normal.\n" "$WARNINGMSG" "$prefile" + if [[ -f $prefile ]]; then + rm "$prefile" + fi + elif [[ "$pre_or_post" == "post" ]]; then + if [[ -f $prefile ]]; then + postnum=$($snapper_cmd --description "$PACMAN_POST_DESCRIPTION" --print-number --pre-number "$(< "$prefile")") + printf "%s %s\n" "$postnum" "$checkmark" + rm "$prefile" + else + printf "N/A\n" + printf " %b %s does not exist, so no post snapshot for %s will be taken. If you are initially installing snap-pac, this is normal.\n" "$WARNINGMSG" "$prefile" "$CONFIG" + fi fi else