diff --git a/misc/build.func b/misc/build.func index 016279e0..a7336f82 100644 --- a/misc/build.func +++ b/misc/build.func @@ -2999,7 +2999,7 @@ create_lxc_container() { msg_info "Searching for template '$TEMPLATE_SEARCH'" # Build regex patterns outside awk/grep for clarity - SEARCH_PATTERN="^${TEMPLATE_SEARCH}-" + SEARCH_PATTERN="^${TEMPLATE_SEARCH}" echo "[DEBUG] TEMPLATE_SEARCH='$TEMPLATE_SEARCH'" echo "[DEBUG] SEARCH_PATTERN='$SEARCH_PATTERN'" @@ -3016,9 +3016,11 @@ create_lxc_container() { echo "[DEBUG] pveam available output (first 5 lines with .tar files):" pveam available -section system 2>/dev/null | grep -E '\.(tar\.zst|tar\.xz|tar\.gz)$' | head -5 | sed 's/^/ /' + set +u mapfile -t ONLINE_TEMPLATES \ \ - echo "[DEBUG] After filtering: ${#ONLINE_TEMPLATES[@]} online templates found" < <(pveam available -section system 2>/dev/null | grep -E '\.(tar\.zst|tar\.xz|tar\.gz)$' | awk -F'\t' '{print $1}' | grep -E "${SEARCH_PATTERN}.*${TEMPLATE_PATTERN}" | sort -t - -k 2 -V 2>/dev/null || true) + echo "[DEBUG] After filtering: ${#ONLINE_TEMPLATES[@]} online templates found" < <(pveam available -section system 2>/dev/null | grep -E '\.(tar\.zst|tar\.xz|tar\.gz)$' | awk '{print $2}' | grep -E "${SEARCH_PATTERN}.*${TEMPLATE_PATTERN}" | sort -t - -k 2 -V 2>/dev/null || true) + set -u if [[ ${#ONLINE_TEMPLATES[@]} -gt 0 ]]; then echo "[DEBUG] Online templates:" for tmpl in "${ONLINE_TEMPLATES[@]}"; do