From f02124b9e6c05a225b079347255c09c62a8ae158 Mon Sep 17 00:00:00 2001 From: AM-SoFT Support Date: Sun, 30 Oct 2022 15:37:08 +0100 Subject: [PATCH] Improve support for snap paths starting with .btrfs/... in case of having some BTRFS volume mounted and named / only. --- btrfs-auto-snapshot | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/btrfs-auto-snapshot b/btrfs-auto-snapshot index 74eb74e..cfc18db 100755 --- a/btrfs-auto-snapshot +++ b/btrfs-auto-snapshot @@ -570,8 +570,8 @@ btrfs_snaps_rm_if() # it's somewhat safe to remove based on conventions. snaps="$(btrfs subvolume list -g -o -s --sort=gen "${i}")" paths="$(echo "${snaps}" | sort -r -n -k 4 | awk '{print $NF}')" - paths="$(echo "${paths}" | sed "\#/${DEF_SNAPS_DIR}/#!d")" - paths="$(echo "${paths}" | sed -r "s!^.+/${DEF_SNAPS_DIR}/!${i}/${DEF_SNAPS_DIR}/!")" + paths="$(echo "${paths}" | sed -r "\#/?${DEF_SNAPS_DIR}/#!d")" + paths="$(echo "${paths}" | sed -r "s!^(.+/)?${DEF_SNAPS_DIR}/!${i}/${DEF_SNAPS_DIR}/!")" paths="$(echo "${paths}" | sed -r "s!^//${DEF_SNAPS_DIR}/!/${DEF_SNAPS_DIR}/!")" paths="$(echo "${paths}" | sed -r "\#/${DEF_SNAPS_DIR}/${snap_patt}#!d")" paths="$(echo "${paths}" | tail -n "+$((keep + 1))")"