Allow spaces in extra args (#112)

* Allow spaces in extra args

Fixes #111

* Fix linter

* Preserve space by iterating
This commit is contained in:
Erik Westrup
2023-05-21 23:19:43 +02:00
committed by GitHub
parent 20b5fd301e
commit 184e426ec8
2 changed files with 8 additions and 3 deletions

View File

@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Warn on certain unset envvars instead of error-exit.
- Allow escaped spaces in EXTRA_ARGS.
## [7.4.0] - 2023-03-08
### Added

View File

@@ -9,7 +9,7 @@
# $ restic_backup.sh
# Exit on error, unset var, pipe failure
set -euo pipefail
set -eo pipefail
# Clean up lock if we are killed.
# If killed by systemd, like $(systemctl stop restic), then it kills the whole cgroup and all it's subprocesses.
@@ -57,10 +57,14 @@ warn_on_missing_envvars \
B2_ACCOUNT_ID B2_ACCOUNT_KEY B2_CONNECTIONS \
RESTIC_PASSWORD_FILE
# Convert to arrays, as arrays should be used to build command lines. See https://github.com/koalaman/shellcheck/wiki/SC2086
IFS=':' read -ra backup_paths <<< "$RESTIC_BACKUP_PATHS"
IFS=' ' read -ra extra_args <<< "$RESTIC_BACKUP_EXTRA_ARGS"
# Convert to array, an preserve spaces. See #111
extra_args=( )
while IFS= read -r -d ''; do
extra_args+=( "$REPLY" )
done < <(xargs printf '%s\0' <<<"$RESTIC_BACKUP_EXTRA_ARGS")
B2_ARG=
[ -z "${B2_CONNECTIONS+x}" ] || B2_ARG=(--option b2.connections="$B2_CONNECTIONS")