From 8ebb5071a4b6f1ce6612db591ccfe0795ff1fb98 Mon Sep 17 00:00:00 2001 From: sometimesuseful <> Date: Tue, 12 Nov 2024 16:03:02 +0000 Subject: [PATCH] added strict mode, fixed unbound variables caused by it --- modules/archive.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/archive.sh b/modules/archive.sh index 207188e..f5ee030 100755 --- a/modules/archive.sh +++ b/modules/archive.sh @@ -3,6 +3,8 @@ # It can (optionally) split the archives into volumes of a fixed size in megabytes. source functions.sh +set -euo pipefail + trap 'cleanup' ERR INT cleanup() { @@ -49,11 +51,11 @@ calc_smart_volumes() { set_volumes() { local input_file="$1" - local size="$2" + local size="${2:-}" local volumes="" if [[ -n "$size" ]]; then - smart_size="$(calc_smart_volumes $input_file || echo -n)" + smart_size="$(calc_smart_volumes $input_file $size || echo -n)" volumes="-v${smart_size}m" fi @@ -98,10 +100,10 @@ main() { exit 1 fi - volumes="$(set_volumes $size)" + volumes="$(set_volumes $input_file $size)" archive="$(generate_name)" - log "NOTICE" "Packing '${input_file}' into archive '$archive' with password '${archive_pwd}'" + log "INFO" "Packing '${input_file}' into archive '$archive' with password '${archive_pwd}'" create_archive \ "$input_file" \