1. Kaspar Schiess
  2. zfs-tools

Commits

Kaspar Schiess  committed effdba4

Minor corrections

  • Participants
  • Parent commits 1631e9f
  • Branches master

Comments (0)

Files changed (1)

File bin/zfs_safe_destroy

View file
 
 def enumerate_objects dataset
   zfs = Mixlib::ShellOut.new(
-    'zfs list -r -Ho name,type ', dataset)
+    'zfs', 'list -r -t all -Ho name,type ', dataset)
   zfs.run_command
   zfs.error!
 
     name, _, type = line.chomp.rpartition(' ')
     name.strip!
 
+    next if name.size == 0
+
     summary[type] += 1
   end
 
   exit(3)
 end
 def zfs_recursive_destroy dataset
-  destroy = Mixlib::ShellOut.new('zfs destroy -r ', dataset)
+  destroy = Mixlib::ShellOut.new('zfs', 'destroy -r ', dataset)
   destroy.run_command
   destroy.error!
+
+rescue => ex
+  warn ex.to_s
+  warn "Aborting."
+  exit(4)
 end
 
 # ----------------------------------------------------------------- main logic
 
 puts "You're about to permanently destroy: "
 before.each do |type, count|
-  printf "%20s %d\n", type, count
+  printf "%5d %ss\n", count, type
 end
 
 puts "\n'zfs destroy -r #{dataset}'"
 print "Please confirm the operation by typing 'yes': "
-confirmation = gets
+confirmation = $stdin.gets
 exit(1) unless confirmation.chomp == 'yes'
 
 after = enumerate_objects(dataset)