From 6a1fc6b69385bfe8a857aff2a658edc8182c6228 Mon Sep 17 00:00:00 2001 From: Fredrik Salomonsson Date: Tue, 26 Mar 2024 22:28:27 -0700 Subject: [PATCH] Use find + sort instead of ls in link-latest command in baksnapperd Shellcheck gives a warning to avoid using ls in for loop as the output is unreliable. Replacing it with find then piped to sort to make it happy. --- baksnapperd.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/baksnapperd.sh b/baksnapperd.sh index f293f4d..dd0cee5 100755 --- a/baksnapperd.sh +++ b/baksnapperd.sh @@ -121,7 +121,8 @@ case "$1" in error "$1/latest exists and is not a symbolic link. Link is not created." fi fi - for dir in $( ls -d1v "$1"/* ); do + for dir in $(find "$1" -maxdepth 1 -mindepth 1 -type d -printf "%P\n"|sort --version-sort) + do if [[ -d "$dir/snapshot" && ! -h "$dir" ]]; then snapshots+=("$dir") fi