From patchwork Sun May 4 21:56:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Prindeville X-Patchwork-Id: 2080907 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=CoA7qaUf; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (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 legolas.ozlabs.org (Postfix) with ESMTPS id 4ZrJRl2vlQz1yY8 for ; Mon, 5 May 2025 07:57:39 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type:List-Help: Reply-To:List-Archive:List-Unsubscribe:List-Subscribe:From:List-Post:List-Id: Message-ID:MIME-Version:Date:Subject:To:Cc:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=K+fJXYUuL3QoiOvXCUF56iwubsDQwJXg35RXWyTffIU=; b=CoA7qaUfrrOiqQTQGfyRzYzgCi EJZDtbnUqJ8ZbBK+a+oZDdaiVPnwg/vAqX/3rP87mtRJC7HYqnT/i758Fp7w5pWaHo4irW2nSAo9b FbI1mbYD1g9s64ywRyQOkdsihTVy4f/+PXN1RqZAMU/EHiS5XbKAjDoFi51NEBTH8K3+HV6edqh2L 77pzrGiSQnoWnA1KQv1L0Qgh9z2h3vM9TqIX8aiWxJjepYgrM/IlYeqnQjNS24uJmlehKgcW76HA1 zgEJkPi9wG97+0YowvKq32j0hCyVGyLnJKKY3JnWx5gLYJjAwwSdDJEFmII9TGSOu+PDszVSjS9Ld DaD63J2Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uBhKL-000000060aK-2o9l; Sun, 04 May 2025 21:56:49 +0000 To: openwrt-devel@lists.openwrt.org Subject: [PATCH 1/4] jshn.sh: Send warnings to stderr Date: Sun, 4 May 2025 15:56:45 -0600 MIME-Version: 1.0 Message-ID: List-Id: OpenWrt Development List List-Post: X-Patchwork-Original-From: Philip Prindeville via openwrt-devel From: Philip Prindeville Precedence: list X-Mailman-Version: 2.1.34 X-BeenThere: openwrt-devel@lists.openwrt.org List-Subscribe: , List-Unsubscribe: , List-Archive: Reply-To: Philip Prindeville List-Help: Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org The sender domain has a DMARC Reject/Quarantine policy which disallows sending mailing list messages using the original "From" header. To mitigate this problem, the original message has been wrapped automatically by the mailing list software. From: Philip Prindeville Warnings should uniformly go to stderr. Signed-off-by: Philip Prindeville --- sh/jshn.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/jshn.sh b/sh/jshn.sh index 1d3055711820e5a21ea59cae49e7bf3f56b626d8..3f2f679187db96d77ccf27b15f5fc47cb8ee9796 100644 --- a/sh/jshn.sh +++ b/sh/jshn.sh @@ -309,7 +309,7 @@ json_select() { ;; *) [ -n "$_json_no_warning" ] || \ - echo "WARNING: Variable '$target' does not exist or is not an array/object" + echo "WARNING: Variable '$target' does not exist or is not an array/object" >&2 return 1 ;; esac From patchwork Sun May 4 21:56:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Prindeville X-Patchwork-Id: 2080905 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=2V6YXgxJ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (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 legolas.ozlabs.org (Postfix) with ESMTPS id 4ZrJRj5F1Bz1yPv for ; Mon, 5 May 2025 07:57:37 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type:List-Help: Reply-To:List-Archive:List-Unsubscribe:List-Subscribe:From:List-Post:List-Id: Message-ID:MIME-Version:Date:Subject:To:Cc:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=kQED+FUpAsmPt5U/7ruKIMqTeb19PZevZ2tEFWjVN5U=; b=2V6YXgxJMTE/7755U0qAU9EFdL Eey3SS6bHPXE2fPy9tuBZOPlngjuwgt5WW7J2sLepqPx6pz6XqEj2gG2+aamVQ78QY+a9O/8/bZcU ZLonHVK8TSQiDd1IoxqGvSy/GxkWZrMU7MNwOIGWNlN3K07ZyAi270wjjQ+cfw1Cab6HzRaXLSjnL /cAIb5jgYuqnZx62hQe+S/Dn0fr2QdsK62O/cKWU6mSxwu57vRe7fCRM0gNKFj54GMReSRguEM5Yi BDb3SS3NJUugCE+zkwHyKkx3F8i71ZSWGAkkCDRjsRVPX4Db6+V4w6PlGtwHluXebld1OTaRYMaZr Wpqd9GrA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uBhKM-000000060ac-3Lt7; Sun, 04 May 2025 21:56:50 +0000 To: openwrt-devel@lists.openwrt.org Subject: [PATCH 2/4] jshn.sh: Drop extraneous space when appending Date: Sun, 4 May 2025 15:56:45 -0600 MIME-Version: 1.0 Message-ID: List-Id: OpenWrt Development List List-Post: X-Patchwork-Original-From: Philip Prindeville via openwrt-devel From: Philip Prindeville Precedence: list X-Mailman-Version: 2.1.34 X-BeenThere: openwrt-devel@lists.openwrt.org List-Subscribe: , List-Unsubscribe: , List-Archive: Reply-To: Philip Prindeville List-Help: Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org The sender domain has a DMARC Reject/Quarantine policy which disallows sending mailing list messages using the original "From" header. To mitigate this problem, the original message has been wrapped automatically by the mailing list software. From: Philip Prindeville Don't unnecessarily add a space before the first value when appending to a list. Signed-off-by: Felix Fietkau Signed-off-by: Philip Prindeville --- sh/jshn.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/jshn.sh b/sh/jshn.sh index 3f2f679187db96d77ccf27b15f5fc47cb8ee9796..3657642fd7673eeb417b0148af3e0b7c1e5c0825 100644 --- a/sh/jshn.sh +++ b/sh/jshn.sh @@ -23,7 +23,7 @@ __jshn_raw_append() { _jshn_append() { # var=$1 local _a_value="$2" - eval "${JSON_PREFIX}$1=\"\${${JSON_PREFIX}$1} \$_a_value\"" + eval "${JSON_PREFIX}$1=\"\${${JSON_PREFIX}$1}\${${JSON_PREFIX}$1:+ }\$_a_value\"" } _get_var() { From patchwork Sun May 4 21:56:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Prindeville X-Patchwork-Id: 2080908 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=dF/FPF01; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (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 legolas.ozlabs.org (Postfix) with ESMTPS id 4ZrJRl6fz1z1yPv for ; Mon, 5 May 2025 07:57:39 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type:List-Help: Reply-To:List-Archive:List-Unsubscribe:List-Subscribe:From:List-Post:List-Id: Message-ID:MIME-Version:Date:Subject:To:Cc:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=59/BdRhorMUlaYSmdoxp35mXTu2CksCABnqEZReSc4o=; b=dF/FPF012cFwimiWQNx/fOJGwh 1nGxjGJU1FPP0NdQj43N3HtmkjtDyBp1sAZI+JSbWLNx8YmHyjC07dPrIQr/IVHWvjDocnfgr4yjn A6ORy+SQBukfywT01gpiyDqorz20csqnCQwQYzBBr9sfj40c2pTkJKgVq0n3JenlnCacRcA81bEEs qIIKnWNidfXkHs3vlE7VUdqSJIzhfXbegScY6QG1DUU+Ui1KYW5Yq3f+QhWvw8OxtQo/IdMSalhwq Cw1XL7lvthlkBzlQEjbvXbZtQKyadRTQvG5I436sucbX8fv19SelgxCJ3FmavnATUz14nqyu3t59l QKWUtCXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uBhKO-000000060bI-0FDY; Sun, 04 May 2025 21:56:52 +0000 To: openwrt-devel@lists.openwrt.org Subject: [PATCH 3/4] jshn.sh: Name positional arguments Date: Sun, 4 May 2025 15:56:46 -0600 MIME-Version: 1.0 Message-ID: List-Id: OpenWrt Development List List-Post: X-Patchwork-Original-From: Philip Prindeville via openwrt-devel From: Philip Prindeville Precedence: list X-Mailman-Version: 2.1.34 X-BeenThere: openwrt-devel@lists.openwrt.org List-Subscribe: , List-Unsubscribe: , List-Archive: Reply-To: Philip Prindeville List-Help: Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org The sender domain has a DMARC Reject/Quarantine policy which disallows sending mailing list messages using the original "From" header. To mitigate this problem, the original message has been wrapped automatically by the mailing list software. From: Philip Prindeville Document the positional arguments to functions, and then use those named variables inside the functions. Signed-off-by: Philip Prindeville --- sh/jshn.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sh/jshn.sh b/sh/jshn.sh index 3657642fd7673eeb417b0148af3e0b7c1e5c0825..c10ff3f154353c9a39b6b8ea9646464211450d86 100644 --- a/sh/jshn.sh +++ b/sh/jshn.sh @@ -222,6 +222,7 @@ json_dump() { } json_get_type() { + # target=$2 local __dest="$1" local __cur @@ -291,11 +292,11 @@ json_select() { local type local cur - [ -z "$1" ] && { + [ -z "$target" ] && { _json_set_var JSON_CUR "J_V" return 0 } - [[ "$1" == ".." ]] && { + [[ "$target" == ".." ]] && { _json_get_var cur JSON_CUR _json_get_var cur "U_$cur" _json_set_var JSON_CUR "$cur" @@ -316,6 +317,8 @@ json_select() { } json_is_a() { + # target=$1 + # type=$2 local type json_get_type type "$1" From patchwork Sun May 4 21:56:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Prindeville X-Patchwork-Id: 2080909 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=IHSbUOIU; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (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 legolas.ozlabs.org (Postfix) with ESMTPS id 4ZrJRm3ZJMz1yY8 for ; Mon, 5 May 2025 07:57:40 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type:List-Help: Reply-To:List-Archive:List-Unsubscribe:List-Subscribe:From:List-Post:List-Id: Message-ID:MIME-Version:Date:Subject:To:Cc:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=82lQ7lv+DtnC9HrkZ9UmXKZUifcqSkPXvC+xev/o9vg=; b=IHSbUOIUt9Gc5E5uZqigxF/81A LKEh61Ygrg5dItSFWXHbtuWMesQkp+5/1LIlyEtH29tgGRYpEdboYOZWTVoiIBi+vPI4zgiteejSA Zui0eeFzlSZ0c197Xfo5KtQIjG4ZOqUXli1uermMouSDwNROncqJN+VIVwL7H5oIWcB50pMD6S9GG 7Dw1yfRX/Y9kaR1zo5FhZwOr20i5Wu73g9JDrMNQ+rjuLWAL7yyTg9ZTD/cDV+b1l+7C+fcS/lA9h jb2SGfYOF8eqlHKqgVYFo4pfhXqGSmkS1JGzfCdKyirzF28QnQQSg0lKziMboRB3OXPK8aEy7EJmo qg0+7NAA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uBhKP-000000060be-0vGW; Sun, 04 May 2025 21:56:53 +0000 To: openwrt-devel@lists.openwrt.org Subject: [PATCH 4/4] jshn.sh: Add anonymous strings in arrays Date: Sun, 4 May 2025 15:56:46 -0600 MIME-Version: 1.0 Message-ID: List-Id: OpenWrt Development List List-Post: X-Patchwork-Original-From: Philip Prindeville via openwrt-devel From: Philip Prindeville Precedence: list X-Mailman-Version: 2.1.34 X-BeenThere: openwrt-devel@lists.openwrt.org List-Subscribe: , List-Unsubscribe: , List-Archive: Reply-To: Philip Prindeville List-Help: Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org The sender domain has a DMARC Reject/Quarantine policy which disallows sending mailing list messages using the original "From" header. To mitigate this problem, the original message has been wrapped automatically by the mailing list software. From: Philip Prindeville Add convenience function to add anonymous strings to arrays. --- sh/jshn.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sh/jshn.sh b/sh/jshn.sh index c10ff3f154353c9a39b6b8ea9646464211450d86..d961926d3bc72c842bb841220bfd17d429d2fc6c 100644 --- a/sh/jshn.sh +++ b/sh/jshn.sh @@ -150,6 +150,17 @@ json_add_string() { _json_add_generic string "$1" "$2" "$cur" } +json_push_string() { + local cur + _json_get_var cur JSON_CUR + [ "${cur%%[0-9]*}" = "J_A" ] || { + [ -n "$_json_no_warning" ] || \ + echo "WARNING: Not in an array" >&2 + return 1 + } + _json_add_generic string "" "$2" "$cur" +} + json_add_int() { local cur _json_get_var cur JSON_CUR