Skip to content

Commit 32e6e25

Browse files
committed
Fix issue when destroying snapshot of top-level dataset
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 '/'.
1 parent 5945c79 commit 32e6e25

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: zap

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ destroy () {
200200
[ -n "$v_opt" ] && printf "%s\nDestroying snapshots...\n" "$(date)"
201201
for i in $(zfs list -H -t snap -o name); do
202202
if echo "$i" | grep -E -q "$zptn"; then
203-
pool="${i%%/*}"
203+
pool="${i%%[/@]*}"
204204
# Do not quote $D_opt, but ensure it does not contain spaces.
205205
if ! pool_ok $D_opt "$pool"; then
206206
warn "Did not destroy $i because of pool state."

0 commit comments

Comments
 (0)