From patchwork Mon May 20 09:05:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7792 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4VjWsS4dxwz3wxG for ; Mon, 20 May 2024 09:06:52 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4VjWsB3CkPz5mj; Mon, 20 May 2024 09:06:38 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4VjWs82DbSz337C; Mon, 20 May 2024 09:06:36 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4VjWs429kcz32W4 for ; Mon, 20 May 2024 09:06:32 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4VjWs401sPz5XX; Mon, 20 May 2024 09:06:31 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1716195992; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FIgGoulRE2LCqq6Rfb6zbtqk/V7YdU+tbS8NXmQVEac=; b=X1YxTHIcHfJUTDC18eBiWZ8qDY3WLFzjlCopJPahldlveR3UrYJkwdVmMaiqiqU6Tys92N EGepM5826wtrKLAA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1716195992; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FIgGoulRE2LCqq6Rfb6zbtqk/V7YdU+tbS8NXmQVEac=; b=QOIJ/gG5C/Cp0ugxcMJrmMpGunBgVu4hAeh+n0O2HcBRiZGkpfB+flut/67j+wEY9FrkOM zSNH+lbm426OUVy5Tc5eNj5v3d0W5fkS1hcTd3Y17fV/Sa8MR6281z6mnTc3W7+dhHmda6 qMGXRhMffDPpjVfK+dvcDNMgP3W9sRWA8CBkT0iuOqMkrofhcf1qWmjAykNwqpzE13ehrY +RT4/grjQrDbl0iswskuCbPPGupBd+4NlSVnIO3IEwCy8nk5vZANSz8Cu/SW0HhMPGlyOr ey10N3qq8jPlALELHDBU9xIbmC03i0713uDzoNjz8vMMTbi6FIiy3MSNtMU4KA== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH 07/21] tests/lib.sh: Fix check if array is defined Date: Mon, 20 May 2024 11:05:57 +0200 Message-Id: <20240520090611.10406-8-jonatan.schlag@ipfire.org> In-Reply-To: <20240520090611.10406-1-jonatan.schlag@ipfire.org> References: <20240520090611.10406-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: VOE6M2VS6PGXVGDCAXHCAGMYA4PG6MM5 X-Message-ID-Hash: VOE6M2VS6PGXVGDCAXHCAGMYA4PG6MM5 X-MailFrom: jonatan.schlag@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: -v does a bad job here. We need to use declare here. Signed-off-by: Jonatan Schlag --- tests/lib.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/lib.sh b/tests/lib.sh index 079755410..0f4de8e43 100644 --- a/tests/lib.sh +++ b/tests/lib.sh @@ -29,10 +29,11 @@ var_has_value() { test_that_key_in_arry_has_value() { local array="${!1}" + local arrayname="${1}" local key="${2}" local value="${3}" - if [[ ! -v "${array}" ]]; then + if [[ ! "$(declare -p "${arrayname}")" =~ "declare -a" && ! "$(declare -p "${arrayname}")" =~ "declare -A" ]]; then log_test_failed "The array '${1}' does not exists. The variable is not set." return 1 fi