diff mbox series

[4/4] jshn.sh: Add anonymous strings in arrays

Message ID mailman.44921.1746395809.1866309.openwrt-devel@lists.openwrt.org
State New
Headers show
Series [1/4] jshn.sh: Send warnings to stderr | expand

Commit Message

Philip Prindeville May 4, 2025, 9:56 p.m. UTC
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 <philipp@redfish-solutions.com>

Add convenience function to add anonymous strings to arrays.

---
 sh/jshn.sh | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox series

Patch

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