Skip to content

Commit

Permalink
Use find + sort instead of ls in link-latest command in baksnapperd
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
plattfot committed Mar 27, 2024
1 parent 530fcd5 commit 6a1fc6b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion baksnapperd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6a1fc6b

Please # to comment.