aboutsummaryrefslogtreecommitdiffstats
path: root/squashfu
diff options
context:
space:
mode:
authorDave Reisner <d@falconindy.com>2010-01-19 21:03:21 -0500
committerDave Reisner <d@falconindy.com>2010-01-19 21:03:21 -0500
commitde0275de2371a5b57f45917ff988c256b9f97f23 (patch)
tree92b2803769639cd64e33eb936f48a98aef1308c2 /squashfu
parent238fc48ec5c4920b5eaaa957a6ada2cb841711dc (diff)
downloadsquashfu-de0275de2371a5b57f45917ff988c256b9f97f23.tar.gz
Restructure action_remove_bin
Diffstat (limited to 'squashfu')
-rwxr-xr-xsquashfu41
1 files 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 () {