diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-14 15:17:32 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-14 15:17:32 +0300 |
| commit | 67231312ba2d80592e305b08bbf03f7aece2e4a3 (patch) | |
| tree | 960a4cf09d741215b3d4c6a2fefbc8c52d09b0ac /src/lib/archive.source.sh | |
| parent | aabe2efbb79938dbbdb4f0ab496cdc22e7280736 (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/archive.source.sh')
| -rw-r--r-- | src/lib/archive.source.sh | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/src/lib/archive.source.sh b/src/lib/archive.source.sh index 127a0c5..3b173b7 100644 --- a/src/lib/archive.source.sh +++ b/src/lib/archive.source.sh @@ -26,27 +26,14 @@ tarball() { resolve_tar_opts() { local -n options_ref="$1"; shift - local tar_opts_decl - options_ref=() - - if ! tar_opts_decl=$(declare -p TAR_OPTS 2>/dev/null); then - options_ref=(-c) - return - fi - - case "$tar_opts_decl" in - declare\ -a*\ TAR_OPTS=*) - options_ref=("${TAR_OPTS[@]}") - ;; - *) - if [ -n "${TAR_OPTS:-}" ]; then - read -r -a options_ref <<< "$TAR_OPTS" - fi - ;; - esac + # Parse TAR_OPTS (array or scalar) via the shared config-array helper, + # then fall back to a plain "-c" whenever no options were configured, + # whether TAR_OPTS was unset or set to an empty value. + resolve_config_array TAR_OPTS options_ref if (( ${#options_ref[@]} == 0 )); then + # shellcheck disable=SC2034 options_ref=(-c) fi } |
