From patchwork Sun Sep 20 05:31:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 1367785 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BvGT96cl8z9sSW for ; Sun, 20 Sep 2020 15:33:49 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe :List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:To:From: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=9EUEYEZF6NmQR93IUZggugBHAbgOF1u1WQ7qD5UIJ+w=; b=m8zyWVUWgxv2TlgHTQEH6A/a9l J7OdwUpe9dziiMwrzaE6lgTOGNqAGy9hpHtrH6YRe0osyY9EJYiC5kILemlCuynHphISMiA2EbGUe xYIi5NHRAVXzi2h97bHY4tvb1QqspSmamiXX7pnjqVWC1bCfPLrAZc5tzhXS8hXEdDueTn90VOt3r E58ahXpzjljHz4wTjv4epEtcZNfb/BzipCAW+Sm+Ouv/j8ylqFwDqVcttDVil42ouV1DnYlJhgKH5 Q9hkBWHD7iRjUt0hxouENHtmPnDeez3bxNU2l2R7Eo+Ij+quIASpPMHcv+MabzzyKaGHiOWUA0YVO NRQVYzAw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kJrx4-0004NU-U2; Sun, 20 Sep 2020 05:31:54 +0000 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kJrwx-0004Lj-C9 for openwrt-devel@lists.openwrt.org; Sun, 20 Sep 2020 05:31:48 +0000 Received: by mail-pj1-x102b.google.com with SMTP id bw23so2625537pjb.2 for ; Sat, 19 Sep 2020 22:31:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=KktsdP00KvCJvGeB6WXogsQEgbDGrLSMgpwUa6H3ims=; b=nBJR1f5w7XlShJA6H/FT0ZNF17Y6MTQ+XiC0ImP2/AvmZsnNnmf/AdMOE2GB3+d77D I19lcpIKkvK6ErsKXE9E9et0X/iUoUNc3HxTPxRuegbRqQq/NFetG3ZadFjnL9d4QOdT FD2/7lTgXxvbPfi88Qc+DKzGDoHWPJI5VquZwee5dv4Hrl+0tiT+vzzDIFgl4Mwxo829 Rsp144jdfE/3Ab7NHzeW02LrfxWUmadOki5Eo6UJBrtxg5Vo4JAyheif0Q0zz4ZZ6qH/ Dg5MbxxsRm2D1n0d/0gmZ8ind4NUDBhbeMi66+zn3lIX7nHpn7Ljowo3u8IAbw+gFk+X ydVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KktsdP00KvCJvGeB6WXogsQEgbDGrLSMgpwUa6H3ims=; b=hi6Ppmnn02oSUXp67EpBMe8s9M9wxfzlzHMICBBdgJ+5+uD1HqUWf9UpQ4N3Bwlw6O 8WLavRca5Nj/i+DJYaKw9U1TJmJPFGPXoApej5SXaE1Tf1wk/8WnbFw+3Q3oRZAU/UPn /3IVNaJv19Bjq8IIczioLJzvUJGsiIzU/zVetszZfXoUMnAoYMGyenFuQP3mxnY8lq2V WMGnnMsmwsB9nJqzqeKpfHWH0JSiVpBpbCVZkBCmCfKS0pL2bFYi6QxmLRwK+tkU0nYe j/L82cWg2FdC5Ga7E2y29DB4i3JUy7pf3k7PUtxQQHdCmLMDR8j9NdKGPvUeJJBDWwjL YwYg== X-Gm-Message-State: AOAM532BPkpzGsI0qR7CUWKo9MEQ6EhMABb5Xd2f6PMabt1d8KYKGZ7E OhnMLDxMi0jMJAmExWmKaGsnkGxXpsit0A== X-Google-Smtp-Source: ABdhPJw630iKSF0hby+9yY5WpkpLR2RCK6NIaZCYSU03a9xy5FgZZbe4teU1EzuKWffvHZL7dIeLXw== X-Received: by 2002:a17:902:6802:b029:d2:253:7fd6 with SMTP id h2-20020a1709026802b02900d202537fd6mr12589174plk.55.1600579905123; Sat, 19 Sep 2020 22:31:45 -0700 (PDT) Received: from mangix-trapnet.lan ([2001:470:1f05:79e::a89]) by smtp.gmail.com with ESMTPSA id 25sm8052450pfj.35.2020.09.19.22.31.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Sep 2020 22:31:44 -0700 (PDT) From: Rosen Penev To: openwrt-devel@lists.openwrt.org Subject: [PATCH 4/4] base-files/functions.sh: quote variables in [] Date: Sat, 19 Sep 2020 22:31:40 -0700 Message-Id: <20200920053140.35255-4-rosenp@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200920053140.35255-1-rosenp@gmail.com> References: <20200920053140.35255-1-rosenp@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200920_013147_419645_D8005E0A X-CRM114-Status: GOOD ( 13.07 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:102b listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [rosenp[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org ash does not support [[]] syntax, which makes this redundant. Found with https://github.com/koalaman/shellcheck/wiki/Sc2086 Signed-off-by: Rosen Penev --- package/base-files/files/lib/functions.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh index a7ff50cb1a..8ada3c376a 100755 --- a/package/base-files/files/lib/functions.sh +++ b/package/base-files/files/lib/functions.sh @@ -92,7 +92,7 @@ list() { local len config_get len "$CONFIG_SECTION" "${varname}_LENGTH" 0 - [ $len = 0 ] && append CONFIG_LIST_STATE "${CONFIG_SECTION}_${varname}" + [ "$len" = 0 ] && append CONFIG_LIST_STATE "${CONFIG_SECTION}_${varname}" len=$((len + 1)) config_set "$CONFIG_SECTION" "${varname}_ITEM$len" "$value" config_set "$CONFIG_SECTION" "${varname}_LENGTH" "$len" @@ -164,7 +164,7 @@ config_list_foreach() { config_get len "${section}" "${option}_LENGTH" [ -z "$len" ] && return 0 - while [ $c -le "$len" ]; do + while [ "$c" -le "$len" ]; do config_get val "${section}" "${option}_ITEM$c" eval "$function \"\$val\" \"\$@\"" c="$((c + 1))"