From ea68dea83f72db325a533811931f0e47b06c5d40 Mon Sep 17 00:00:00 2001 From: Ravinou Date: Sun, 8 Oct 2023 16:57:13 +0200 Subject: [PATCH] fix: return a empty json if there are no repo to stat --- helpers/shells/getLastSave.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/helpers/shells/getLastSave.sh b/helpers/shells/getLastSave.sh index 452a000..a7ca79f 100755 --- a/helpers/shells/getLastSave.sh +++ b/helpers/shells/getLastSave.sh @@ -26,6 +26,10 @@ fi # Default value if .env not exists : "${home:=/home/borgwarehouse}" -stat --format='{"repositoryName":"%n","lastSave":%Y}' \ +if [ -n "$(find ${home}/repos -mindepth 1 -maxdepth 1 -type d)" ]; then + stat --format='{"repositoryName":"%n","lastSave":%Y}' \ ${home}/repos/*/integrity* | - jq --slurp '[.[] | .repositoryName = (.repositoryName | split("/")[-2])]' \ No newline at end of file + jq --slurp '[.[] | .repositoryName = (.repositoryName | split("/")[-2])]' +else + echo "[]" +fi \ No newline at end of file