Skip to content

Commit

Permalink
Fix issue when destroying snapshot of top-level dataset
Browse files Browse the repository at this point in the history
To extract the pool name from a snapshot name, a parameter expansion was
removing everything after '/'.  However, the top-level dataset contains no '/'
in its name (its name is the same as the pool's name).  This means the entire
snapshot name was being incorrectly returned for the name of the pool.

This commit fixes the parameter expansion to handle the case when the dataset
name contains no '/'.
  • Loading branch information
Jehops committed Aug 18, 2017
1 parent 5945c79 commit 32e6e25
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion zap
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ destroy () {
[ -n "$v_opt" ] && printf "%s\nDestroying snapshots...\n" "$(date)"
for i in $(zfs list -H -t snap -o name); do
if echo "$i" | grep -E -q "$zptn"; then
pool="${i%%/*}"
pool="${i%%[/@]*}"
# Do not quote $D_opt, but ensure it does not contain spaces.
if ! pool_ok $D_opt "$pool"; then
warn "Did not destroy $i because of pool state."
Expand Down

0 comments on commit 32e6e25

Please sign in to comment.