Skip to content

Commit

Permalink
Merge pull request pr1ntf#143 from moogle19/delete_bug
Browse files Browse the repository at this point in the history
Fix deletion of partly matching datasets
  • Loading branch information
trent-pr1ntf committed May 6, 2016
2 parents 2f97c0b + f571c44 commit 231ddd1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/ioh-guest
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,8 @@ __delete() {
local flagone="$2"
local flagtwo="$3"
if [ $flagone = "-f" ]; then
local target_dataset="$(zfs list -H -t filesystem -o name | grep iohyve | grep $flagtwo | head -n1)"
local pool="$(zfs list -H -t volume | grep iohyve/$flagtwo | cut -d '/' -f 1 | head -n1)"
local target_dataset="$pool/iohyve/$flagtwo"
echo ""
echo "[WARNING] Forcing permanent deletion of $flagtwo"
echo "Location: $target_dataset including children and clones"
Expand All @@ -586,7 +587,8 @@ __delete() {
echo "Deleting $flagtwo at $target_dataset..."
zfs destroy -rR $target_dataset
else
local target_dataset="$(zfs list -H -t filesystem -o name | grep iohyve | grep $flagone | head -n1)"
local pool="$(zfs list -H -t volume | grep iohyve/$flagone | cut -d '/' -f 1 | head -n1)"
local target_dataset="$pool/iohyve/$flagone"
echo ""
echo "[WARNING] Are you sure you want to permanently delete $flagone and all child datasets?"
read -p "Location: $target_dataset [Y/N]? " an </dev/tty
Expand Down

0 comments on commit 231ddd1

Please sign in to comment.