From 67231312ba2d80592e305b08bbf03f7aece2e4a3 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 14 Jun 2026 15:17:32 +0300 Subject: 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 --- tests/cli.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'tests/cli.sh') diff --git a/tests/cli.sh b/tests/cli.sh index d6fbbd4..b8b56f6 100755 --- a/tests/cli.sh +++ b/tests/cli.sh @@ -1677,6 +1677,34 @@ test_print_config_normalizes_scalar_and_array_tar_opts() { test::teardown } +test_print_config_empty_tar_opts_falls_back_to_default() { + local config_file + local empty_array_output + local empty_scalar_output + + test::setup + config_file="$TEST_TMPDIR/shuriken.conf" + test::write_album_config \ + "$config_file" "$TEST_TMPDIR/incoming" "$TEST_TMPDIR/dist" \ + 'Empty tar opts' 40 + + # An empty scalar TAR_OPTS must fall back to the default "-c" just like an + # unset value; the shared resolve_config_array helper yields an empty array + # and resolve_tar_opts supplies the default. + printf 'TAR_OPTS=%q\n' '' >> "$config_file" + empty_scalar_output=$("$TEST_SHURIKEN" --print-config --config "$config_file") + test::assert_contains 'TAR_OPTS=( -c )' "$empty_scalar_output" + + # An empty array declaration must behave identically. + test::write_album_config \ + "$config_file" "$TEST_TMPDIR/incoming" "$TEST_TMPDIR/dist" \ + 'Empty array tar opts' 40 + printf 'TAR_OPTS=()\n' >> "$config_file" + empty_array_output=$("$TEST_SHURIKEN" --print-config --config "$config_file") + test::assert_contains 'TAR_OPTS=( -c )' "$empty_array_output" + test::teardown +} + test_print_config_quiet_and_verbose_keep_machine_output() { local config_file local plain_output @@ -4855,6 +4883,9 @@ main() { test::run_case \ '--print-config normalizes scalar and array TAR_OPTS' \ test_print_config_normalizes_scalar_and_array_tar_opts + test::run_case \ + '--print-config empty TAR_OPTS falls back to default' \ + test_print_config_empty_tar_opts_falls_back_to_default test::run_case \ '--print-config quiet and verbose keep machine output' \ test_print_config_quiet_and_verbose_keep_machine_output -- cgit v1.2.3