From de0275de2371a5b57f45917ff988c256b9f97f23 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Tue, 19 Jan 2010 21:03:21 -0500 Subject: Restructure action_remove_bin --- squashfu | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/squashfu b/squashfu index 570bb88..c4b76fe 100755 --- a/squashfu +++ b/squashfu @@ -278,27 +278,32 @@ action_remove_bin () { die "Error writing to ${BINVENTORY}" fi - if [[ -z $2 && $(grep -E "^$1:" ${BINVENTORY}) && -d "${BINS_DIR}/$1" ]]; then - echo "Are you SURE you want to remove this bin?" - local timestamp=$(sed -n "/$1/s/^[0-9]*://" "${BINVENTORY}") - printf "\t%15s %s\n\t%15s %s\n\t%15s %s\n" \ - "Bin:" "$1" \ - "Date Created:" "$(date --rfc-3339=seconds --date="1970-01-01 $timestamp sec GMT")" \ - "Size:" "$(du -sh "${BINS_DIR}/$1" 2>/dev/null | awk '{print $1}')" - - read -p "Confirm deletion (y/N)" confirm - if [[ $confirm != "y" ]]; then - info "Delete operation aborted" - exit 1 + if [[ $(grep -E "^$1:" ${BINVENTORY}) && -d "${BINS_DIR}/$1" ]]; then + if [[ -z $2 ]]; then + echo "Are you SURE you want to remove this bin?" + local timestamp=$(sed -n "/$1/s/^[0-9]*://" "${BINVENTORY}") + printf "\t%15s %s\n\t%15s %s\n\t%15s %s\n" \ + "Bin:" "$1" \ + "Date Created:" "$(date --rfc-3339=seconds --date="1970-01-01 $timestamp sec GMT")" \ + "Size:" "$(du -sh "${BINS_DIR}/$1" 2>/dev/null | awk '{print $1}')" + + read -p "Confirm deletion (y/N)" confirm + if [[ $confirm != "y" ]]; then + info "Delete operation aborted" + exit 1 + fi fi - fi - info "Deleting bin $1" - sed -i "/^$1:[0-9]*/d" "${BINVENTORY}" - rm -rf ${BINS_DIR}/$1 + info "Deleting bin $1" + sed -i "/^$1:[0-9]*/d" "${BINVENTORY}" + rm -rf ${BINS_DIR}/$1 + + # tidy up! + sweep_bins + else + die "Bin $1 not found." + fi - # tidy up! - sweep_bins } action_rollback () { -- cgit v1.2.3