From f15a2343463b95c5e298db54968d5f31659ddc74 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 9 Sep 2016 09:18:16 +0100 Subject: [PATCH] Use previous blog post index when deleting --- src/freedombone-mesh-blog | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/freedombone-mesh-blog b/src/freedombone-mesh-blog index 7073f733..9602bf3c 100755 --- a/src/freedombone-mesh-blog +++ b/src/freedombone-mesh-blog @@ -105,7 +105,8 @@ function delete_blog { return fi CURRENT_INDEX=$(cat $CURRENT_BLOG_INDEX) - LAST_BLOG_ENTRY=$BLOG_CONTENT_PATH/${CURRENT_INDEX}_post.rst + PREVIOUS_INDEX=$((CURRENT_INDEX - 1)) + LAST_BLOG_ENTRY=$BLOG_CONTENT_PATH/${PREVIOUS_INDEX}_post.rst if [ ! -f $LAST_BLOG_ENTRY ]; then return fi @@ -118,8 +119,10 @@ function delete_blog { case $sel in 0) rm $LAST_BLOG_ENTRY if [ $CURRENT_INDEX -gt 0 ]; then - CURRENT_INDEX=$((CURRENT_INDEX - 1)) + CURRENT_INDEX=$PREVIOUS_INDEX echo "$CURRENT_INDEX" > $CURRENT_BLOG_INDEX + else + rm -f $CURRENT_BLOG_INDEX fi regenerate_blog ;;