added strict mode, fixed unbound variables caused by it
This commit is contained in:
parent
ebbc407b93
commit
8ebb5071a4
1 changed files with 6 additions and 4 deletions
|
|
@ -3,6 +3,8 @@
|
||||||
# It can (optionally) split the archives into volumes of a fixed size in megabytes.
|
# It can (optionally) split the archives into volumes of a fixed size in megabytes.
|
||||||
source functions.sh
|
source functions.sh
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
trap 'cleanup' ERR INT
|
trap 'cleanup' ERR INT
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
|
|
@ -49,11 +51,11 @@ calc_smart_volumes() {
|
||||||
|
|
||||||
set_volumes() {
|
set_volumes() {
|
||||||
local input_file="$1"
|
local input_file="$1"
|
||||||
local size="$2"
|
local size="${2:-}"
|
||||||
local volumes=""
|
local volumes=""
|
||||||
|
|
||||||
if [[ -n "$size" ]]; then
|
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"
|
volumes="-v${smart_size}m"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -98,10 +100,10 @@ main() {
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
volumes="$(set_volumes $size)"
|
volumes="$(set_volumes $input_file $size)"
|
||||||
archive="$(generate_name)"
|
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 \
|
create_archive \
|
||||||
"$input_file" \
|
"$input_file" \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue