]> gitweb.hhaalo.de Git - simple-backup.git/commitdiff
add correct input parameter checks
authorBastian Dehn <hhaalo@arcor.de>
Sat, 24 May 2025 16:57:58 +0000 (18:57 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sat, 24 May 2025 16:57:58 +0000 (18:57 +0200)
backup

diff --git a/backup b/backup
index 5afa0db450c4307666ef17dda1b6c5bf7bfd9503..a719e81d93503292867430f70e087bd64c7bf48f 100755 (executable)
--- a/backup
+++ b/backup
@@ -252,22 +252,22 @@ main()
        backup_name=$(cat config.yaml | yq -r '.backup_name')
        backup_count=$(cat config.yaml | yq -r '.backup_count')
 
-       [ "$backup_path" != "null" ] \
-               || errlog "missing backup path" \
+       [ -n "$backup_path" ] && [ "$backup_path" != "null" ] \
+               || errlog "missing backup_path in config.yaml" \
+               || return $?
+       [ -d "$backup_path" ] \
+               || errlog "directory $backup_path not exists" \
                || return $?
        echo "ℹ️  INFO: backup path $backup_path"
-       [ "$backup_name" != "null" ] \
-               || errlog "missing backup name" \
+       [ -n "$backup_name" ] && [ "$backup_name" != "null" ] \
+               || errlog "missing backup_name in config.yaml" \
                || return $?
        echo "ℹ️  INFO: backup name $backup_name"
-       [ "$backup_count" != "null" ] \
-               || errlog "missing backup count" \
+       [ -n "$backup_count" ] && [ "$backup_count" != "null" ] \
+               || errlog "missing backup_count in config.yaml" \
                || return $?
        echo "ℹ️  INFO: backup count $backup_count"
 
-       [ -d "$backup_path" ] \
-               || errlog "directory $backup_path not exists" \
-               || return $?
 
        local backup_dir=$(get_backup_dir \
                "$backup_path" \