summaryrefslogtreecommitdiff
path: root/src/lib/config.sync.source.sh
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-06-14 15:17:32 +0300
committerPaul Buetow <paul@buetow.org>2026-06-14 15:17:32 +0300
commit67231312ba2d80592e305b08bbf03f7aece2e4a3 (patch)
tree960a4cf09d741215b3d4c6a2fefbc8c52d09b0ac /src/lib/config.sync.source.sh
parentaabe2efbb79938dbbdb4f0ab496cdc22e7280736 (diff)
lm0 de-duplicate imagemagick detection and config-array parsing
Introduce a shared resolve_config_array helper in bootstrap.source.sh that parses a config variable declared as either a Bash array or a whitespace-separated scalar into a named output array. resolve_tar_opts and resolve_sync_destinations now both delegate to it, with resolve_tar_opts keeping its "-c" default for the empty/unset case. validate_imagemagick now reuses resolve_imagemagick_command instead of duplicating the magick/convert probing, reporting failures through config_error so the validation output is unchanged. Add a print-config test covering the empty TAR_OPTS (scalar and array) fallback to the default. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'src/lib/config.sync.source.sh')
-rw-r--r--src/lib/config.sync.source.sh24
1 files changed, 6 insertions, 18 deletions
diff --git a/src/lib/config.sync.source.sh b/src/lib/config.sync.source.sh
index 68bb759..1707fe6 100644
--- a/src/lib/config.sync.source.sh
+++ b/src/lib/config.sync.source.sh
@@ -1,24 +1,12 @@
resolve_sync_destinations() {
+ # destinations_ref is a nameref output filled by resolve_config_array.
+ # shellcheck disable=SC2034
local -n destinations_ref="$1"; shift
- local destinations_decl
- destinations_ref=()
-
- if ! destinations_decl=$(declare -p SYNC_DESTINATIONS 2>/dev/null); then
- return
- fi
-
- case "$destinations_decl" in
- declare\ -a*\ SYNC_DESTINATIONS=*)
- destinations_ref=("${SYNC_DESTINATIONS[@]}")
- ;;
- *)
- if [ -n "${SYNC_DESTINATIONS:-}" ]; then
- # shellcheck disable=SC2034
- read -r -a destinations_ref <<< "$SYNC_DESTINATIONS"
- fi
- ;;
- esac
+ # Parse SYNC_DESTINATIONS (array or scalar) via the shared config-array
+ # helper. Unlike TAR_OPTS there is no default: an unset or empty value
+ # simply yields an empty destinations array for callers to validate.
+ resolve_config_array SYNC_DESTINATIONS destinations_ref
}
sync_dist() {