From 2b9851ba38f9b5eee6433190bb7fbd000c21369f Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Wed, 3 Dec 2025 13:31:17 +0100 Subject: [PATCH] Temporarily disable 'set -u' in cloud-init.func Disables 'unbound variable' errors at the start of the script to prevent issues with unset variables, and restores the previous shell options at the end. This ensures compatibility and avoids unexpected script failures. --- misc/cloud-init.func | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/misc/cloud-init.func b/misc/cloud-init.func index 17f4fefc5..9a5ca45e0 100644 --- a/misc/cloud-init.func +++ b/misc/cloud-init.func @@ -28,6 +28,10 @@ # ============================================================================== # These can be overridden before sourcing this library +# Disable 'unbound variable' errors for this library (restored at end) +_OLD_SET_STATE=$(set +o | grep -E 'set -(e|u|o)') +set +u + CLOUDINIT_DEFAULT_USER="${CLOUDINIT_DEFAULT_USER:-root}" CLOUDINIT_DNS_SERVERS="${CLOUDINIT_DNS_SERVERS:-1.1.1.1 8.8.8.8}" CLOUDINIT_SEARCH_DOMAIN="${CLOUDINIT_SEARCH_DOMAIN:-local}" @@ -459,6 +463,11 @@ export -f wait_for_cloud_init 2>/dev/null || true export -f validate_ip_cidr 2>/dev/null || true export -f validate_ip 2>/dev/null || true +# Restore previous shell options if they were saved +if [ -n "${_OLD_SET_STATE:-}" ]; then + eval "$_OLD_SET_STATE" +fi + # ============================================================================== # SECTION 7: EXAMPLES & DOCUMENTATION # ==============================================================================