From ff963aa844c9d0f3a27a59ae908a324524c7d949 Mon Sep 17 00:00:00 2001 From: hygienic-books Date: Tue, 26 Dec 2023 05:58:07 +0100 Subject: [PATCH] refactor(script): Abort early and with clear msg when no datasets snapshottable (#1) --- pacman-zfs-snapshot.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pacman-zfs-snapshot.sh b/pacman-zfs-snapshot.sh index d047d8b..b7d643a 100755 --- a/pacman-zfs-snapshot.sh +++ b/pacman-zfs-snapshot.sh @@ -375,8 +375,18 @@ function main () { local local_snappable_datasets get_local_snappable_datasets trim_globally_snappable_datasets + if [[ "${#snappable_datasets[@]}" -eq '0' ]]; then + pprint 'info' 'ZFS snapshot skipped, no local (= currently mounted) dataset has' + pprint 'info' 'property '"'"''"${zfs_prop}"''"'"' set to '"'"'true'"'"'. At the same' + pprint 'info' 'time option '"'"'snap_only_local_datasets'"'"' equals '"'"'true'"'"' so' + pprint 'info' 'we must only snapshot local datasets. Nothing to do here while' + pprint 'info' 'none of them have '"'"''"${zfs_prop}"''"'"' set to '"'"'true'"'"'.' '0' + fi else snappable_datasets=("${globally_snappable_datasets}") + if [[ "${#snappable_datasets[@]}" -eq '0' ]]; then + pprint 'info' 'ZFS snapshot skipped, no dataset has property '"'"''"${zfs_prop}"''"'"' set to '"'"'true'"'"'.' '0' + fi fi local unabridged_pkg_list_oneline