fix ignored error
[distro-setup] / check-subvol-stale
index 6a63124cd3ac749028a794117e0da2df384dbcfd..dcc0535e6df227cc3b5b03f56a8a543b8df4eeb3 100644 (file)
@@ -28,7 +28,7 @@ usage: $0 SUBVOL_MOUNTPOINT...
 In git this is not not executable because it's meant to be installed
 using ./install-my-scripts
 
-If latest subvols \$@ are not mounted, exit 1, print message, and print
+If latest subvols \$@ are not mounted, print a message, and print
 the unstale subvol name into /nocow/btrfs-stale/\$subvol
 
 Fresh is opposite of stale. To be fresh, either SUBVOL_MOUNTPOINT is a
@@ -67,7 +67,6 @@ stale-file() {
     if $stale; then
         mkdir -p $stale_dir
         printf "%s\n" $freshest_snap > $stale_file
-        ret=1
     else
         rm -f $stale_file
     fi
@@ -79,7 +78,6 @@ d() {
     fi
 }
 
-ret=0
 for d; do
     vol=${d##*/}
     # second field, non-comment line == $d
@@ -134,9 +132,8 @@ for d; do
              )
     if [[ ! $last_snap ]]; then
         # should not happen.
-        echo "$0: error: could not find latest snapshot for $svp among ${snaps[*]}"
-        ret=1
-        continue
+        echo "$0: error: could not find latest snapshot for $svp among ${snaps[*]}" >&2
+        exit 1
     fi
 
     if [[ ! -e $svp ]]; then
@@ -181,6 +178,4 @@ for d; do
     fi
 
     stale-file
-
 done
-exit $ret