fixes and some improvements
[distro-setup] / check-subvol-stale
index a3d0149e24fa574ccec2d62a5e427db81935851e..286f3ba8b63121a7c3c0f5d51493b383cf84ffe5 100644 (file)
@@ -27,8 +27,9 @@ usage: $0 SUBVOL_MOUNTPOINT... | -p SUBVOL_PATH...
 In git this is not not executable because it's meant to be installed
 using ./install-my-scripts
 
-If latest subvols \$@ are not mounted, print a message, and print
-the unstale subvol name into /nocow/btrfs-stale/\$subvol
+Print the unstale subvol name into /nocow/btrfs-stale/\$subvol
+
+If latest subvols \$@ are not mounted, print a message to terminal.
 
 Fresh is opposite of stale. To be fresh, either SUBVOL_MOUNTPOINT is a
 snapshot of the latest, or the latest snapshot is snapshot of
@@ -83,6 +84,7 @@ d() {
 }
 
 # duplicated in mount-latest-sub
+# Reassign $1 var from /dev/dm- to corresponding /dev/mapper/
 mapper-dev() {
   local mapdev
   local -n devref=$1
@@ -213,7 +215,7 @@ for d; do
   stale=true
   # fresh if $svp has $last_snap as a snapshot,
   if btrfs sub show $svp 2>/dev/null | sed '0,/^\s*Snapshot(s):/d;s/^\s*//' | \
-      grep -xF ${last_snap#$root_dir/} ; then
+      grep -xF ${last_snap#$root_dir/} >/dev/null; then
     stale=false
   else # or else $svp is a snapshot of $last_snap. we use a uuid
     # comparison, which if I remember from the docs, is a bit more