diff --git a/CHANGELOG.md b/CHANGELOG.md index 0080a59..ecd890a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,11 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [3.0.1] - 2022-02-01 +### Fixed +- Environment variable assertion should allow empty values e.g. `RESTIC_BACKUP_EXTRA_ARGS` + ## [3.0.0] - 2022-02-01 ### Added - Allow extra arguments to restic-backup with `$RESTIC_BACKUP_EXTRA_ARGS`. - Add `$RESTIC_VERBOSITY_LEVEL` for debugging. -- Assertion on all needed envionment variables in the backup and check scripts. +- Assertion on all needed environment variables in the backup and check scripts. - Added linter (`shellcheck(1)`) that is run on push and PRs. ### Changed diff --git a/usr/local/sbin/restic_backup.sh b/usr/local/sbin/restic_backup.sh index 053b292..fb2c7f5 100644 --- a/usr/local/sbin/restic_backup.sh +++ b/usr/local/sbin/restic_backup.sh @@ -16,9 +16,8 @@ set -euo pipefail assert_envvars() { local varnames=("$@") for varname in "${varnames[@]}"; do - # Check if variable is set, then if it is not empty (need to do both as of `set -u`). - if [ -z ${!varname+x} ] || [ -z "${!varname}" ] ; then - printf "%s must be set with a value for this script to work.\n\nDid you forget to source a /etc/restic/*.env profile in the current shell before executing this script?\n" "$varname" >&2 + if [ -z ${!varname+x} ]; then + printf "%s must be set for this script to work.\n\nDid you forget to source a /etc/restic/*.env profile in the current shell before executing this script?\n" "$varname" >&2 exit 1 fi done diff --git a/usr/local/sbin/restic_check.sh b/usr/local/sbin/restic_check.sh index bf4d8b5..c44f7f5 100644 --- a/usr/local/sbin/restic_check.sh +++ b/usr/local/sbin/restic_check.sh @@ -9,9 +9,8 @@ set -euo pipefail assert_envvars() { local varnames=("$@") for varname in "${varnames[@]}"; do - # Check if variable is set, then if it is not empty (need to do both as of `set -u`). - if [ -z ${!varname+x} ] || [ -z "${!varname}" ] ; then - printf "%s must be set with a value for this script to work.\n\nDid you forget to source a /etc/restic/*.env profile in the current shell before executing this script?\n" "$varname" >&2 + if [ -z ${!varname+x} ]; then + printf "%s must be set for this script to work.\n\nDid you forget to source a /etc/restic/*.env profile in the current shell before executing this script?\n" "$varname" >&2 exit 1 fi done