From patchwork Mon May 20 09:06:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7805 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 4VjWst2jPnz3wxb for ; Mon, 20 May 2024 09:07:14 +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 4VjWsm2TYBz5nr; Mon, 20 May 2024 09:07:08 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4VjWsX3GHpz32fy; Mon, 20 May 2024 09:06:56 +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 4VjWsV2GcBz32fy for ; Mon, 20 May 2024 09:06:54 +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 4VjWsL5Dfbz15J; Mon, 20 May 2024 09:06:46 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1716196006; 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=qxZ9/olv1XdfcPMKhlM+jDC0B0OpMcP6wKLEySFbCo0=; b=8AGYxekjzwhPH8ADXCN1PYMi2rSc43Xr3bQudaBJgxsEH04wtTRhmoD1wPtxiLXWA3QDq1 5ws1UvpRIKHe1mCA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1716196006; 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=qxZ9/olv1XdfcPMKhlM+jDC0B0OpMcP6wKLEySFbCo0=; b=cVRo/4MAip382RulY0hFT+5MHBN0qz8Fil0TxUo4vf3GF8RyNno/VvDlwP2CHGLFIEaXz2 QHMuajl0wjheGK0GYasdy70HmYAP2S4JnVuHmfPc2vuWJaHFxQ1sojcG9z+EHzl4hJREfU 2WY7GI7au+KFCdndeC419o985SH7B+BiF0szq/vSxeqCFqNRDpvCycXbZ0O9fRfP8pyq1h pOuIixXmSOUHOJUv1I8NrU2gYPbozlX19yijEE+6CHSbn2PNS8Jei+FFpx81o2Rv5zlO+i CU8++iEQJ7c5GTrp2+5ToSRLuop1+j7SE8fn48r9DZJ459Tg1DOId2snsjPwJA== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH 20/21] initscripts fkt: keep readhash compatible with older implementation Date: Mon, 20 May 2024 11:06:10 +0200 Message-Id: <20240520090611.10406-21-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: PHFTJJASBOXZNEQIPZGDEUGQQGJ7Y2JP X-Message-ID-Hash: PHFTJJASBOXZNEQIPZGDEUGQQGJ7Y2JP 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: With the use of eval BLUE_DEV='blue0 net0' stored "blue0 net0" in the variable BLUE_DEV not "'blue0 net0'" Signed-off-by: Jonatan Schlag --- src/initscripts/system/functions | 4 ++++ tests/src/initscripts/system/functions/test.sh | 1 + 2 files changed, 5 insertions(+) diff --git a/src/initscripts/system/functions b/src/initscripts/system/functions index c9c4c0675..6d72e4119 100644 --- a/src/initscripts/system/functions +++ b/src/initscripts/system/functions @@ -932,6 +932,10 @@ readhash() { continue fi + # strip leading and trailing single quotes + val="${val#\'}" + val="${val%\'}" + printf -v "${array}[${key}]" "%s" "${val}" done < "${file}" } diff --git a/tests/src/initscripts/system/functions/test.sh b/tests/src/initscripts/system/functions/test.sh index 9981cc732..1a715d7d9 100755 --- a/tests/src/initscripts/system/functions/test.sh +++ b/tests/src/initscripts/system/functions/test.sh @@ -14,6 +14,7 @@ readhash "CONFIG" "${SCRIPT_PATH}/data/1" # test if we read the correct data test_that_key_in_arry_has_value "CONFIG" "RED_DHCP_HOSTNAME" "ipfire" test_that_key_in_arry_has_value "CONFIG" "BLUE_MACADDR" "bc:30:7d:58:6b:e3" +test_that_key_in_arry_has_value "CONFIG" "BLUE_DEV" "blue0 net0" # Test that comments are skipped # apparently the way we read the file strips the whitespace, so the key does not contain any whitespace either