From 0a678b7f7f231a4a55ef960e3208100d8f9021ba Mon Sep 17 00:00:00 2001 From: "LINUXexpert.org" <51408202+LINUXexpert-org@users.noreply.github.com> Date: Thu, 22 Jan 2026 13:50:05 -0700 Subject: [PATCH] Refactor allowed targets to use arrays in script --- ubuntu-to-mint-convert-v3.sh | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/ubuntu-to-mint-convert-v3.sh b/ubuntu-to-mint-convert-v3.sh index e90c012..4c23b74 100644 --- a/ubuntu-to-mint-convert-v3.sh +++ b/ubuntu-to-mint-convert-v3.sh @@ -147,15 +147,15 @@ detect_ubuntu_codename() { set_targets_from_ubuntu() { UBUNTU_CODENAME="$(detect_ubuntu_codename)" case "$UBUNTU_CODENAME" in - noble) - UBUNTU_BASE="noble" - DEFAULT_MINT="zena" # Mint 22.3 Zena (Ubuntu Noble base) - ALLOWED_TARGETS="zena zara xia wilma" - ;; + noble) + UBUNTU_BASE="noble" + DEFAULT_MINT="zena" # Mint 22.3 Zena (Ubuntu Noble base) + ALLOWED_TARGETS=(zena zara xia wilma) + ;; jammy) UBUNTU_BASE="jammy" DEFAULT_MINT="virginia" # Mint 21.3 on Ubuntu Jammy base - ALLOWED_TARGETS="virginia victoria vera vanessa" + ALLOWED_TARGETS=(virginia victoria vera vanessa) ;; *) die "Unsupported Ubuntu codename '$UBUNTU_CODENAME'. Supports Ubuntu noble (24.04) or jammy (22.04) only." @@ -167,10 +167,19 @@ set_targets_from_ubuntu() { fi local ok_target="no" - for t in $ALLOWED_TARGETS; do - [[ "$TARGET_MINT" == "$t" ]] && ok_target="yes" + for t in "${ALLOWED_TARGETS[@]}"; do + if [[ "$TARGET_MINT" == "$t" ]]; then + ok_target="yes" + break + fi done - [[ "$ok_target" == "yes" ]] || die "--target '$TARGET_MINT' not allowed for Ubuntu '$UBUNTU_CODENAME'. Allowed: $ALLOWED_TARGETS" + + if [[ "$ok_target" != "yes" ]]; then + local allowed_str + printf -v allowed_str '%s ' "${ALLOWED_TARGETS[@]}" + allowed_str="${allowed_str% }" + die "--target '$TARGET_MINT' not allowed for Ubuntu '$UBUNTU_CODENAME'. Allowed: $allowed_str" + fi } preflight_common() {