Made if statements more concise

This commit is contained in:
PedoDeveloper 2024-11-13 11:51:36 +00:00
parent 5d9436d92c
commit 3ea5fcfa15

View file

@ -19,11 +19,7 @@ check_input() {
[[ -e "$input_file" ]] || { log "ERROR" "Input file '${input_file}' does not exist"; exit 2; } [[ -e "$input_file" ]] || { log "ERROR" "Input file '${input_file}' does not exist"; exit 2; }
[[ -n "${password}" ]] || { log "ERROR" "No password given"; exit 2; } [[ -n "${password}" ]] || { log "ERROR" "No password given"; exit 2; }
[[ "$size" =~ ^([1-9][0-9]*)?$ ]] || { log "ERROR" "Invalid size '$size', must be empty or a positive number"; exit 2; }
if [[ ! "$size" =~ ^([1-9][0-9]*)?$ ]]; then
log "ERROR" "Invalid size '$size', must be empty or a positive number"
exit 2
fi
} }
calc_smart_volumes() { calc_smart_volumes() {
@ -93,10 +89,7 @@ main() {
check_dependencies "7z" check_dependencies "7z"
check_input "$input_file" "$password" "$size" check_input "$input_file" "$password" "$size"
if ! mkdir -p "$archive_dir"; then mkdir -p "$archive_dir" || { log "ERROR" "Unable to create archive directory"; exit 1; }
log "ERROR" "Unable to create archive directory"
exit 1
fi
volumes="$(get_volumes "$input_file" "$size")" volumes="$(get_volumes "$input_file" "$size")"
archive_name="$(generate_name)" archive_name="$(generate_name)"