From 6b340e391cff68e6fc2c816cf15ffd67feddf029 Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Fri, 12 Dec 2014 11:51:12 -0700 Subject: [PATCH] Fix a bashism and some minor bugs in nuke-graph-directory.sh Signed-off-by: Andrew Page --- contrib/nuke-graph-directory.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/contrib/nuke-graph-directory.sh b/contrib/nuke-graph-directory.sh index f44c45a174..8d12a9d646 100755 --- a/contrib/nuke-graph-directory.sh +++ b/contrib/nuke-graph-directory.sh @@ -50,9 +50,10 @@ for mount in $(awk '{ print $5 }' /proc/self/mountinfo); do done # now, let's go destroy individual btrfs subvolumes, if any exist -if command -v btrfs &> /dev/null; then +if command -v btrfs > /dev/null 2>&1; then root="$(df "$dir" | awk 'NR>1 { print $NF }')" - for subvol in $(btrfs subvolume list -o "$root" 2>/dev/null | awk -F' path ' '{ print $2 }'); do + root="${root#/}" # if root is "/", we want it to become "" + for subvol in $(btrfs subvolume list -o "$root/" 2>/dev/null | awk -F' path ' '{ print $2 }' | sort -r); do subvolDir="$root/$subvol" if dir_in_dir "$subvolDir" "$dir"; then ( set -x; btrfs subvolume delete "$subvolDir" )