added strict mode, fixed unbound variables caused by it

This commit is contained in:
sometimesuseful 2024-11-12 16:03:02 +00:00
parent ebbc407b93
commit 8ebb5071a4

View file

@ -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" \