From patchwork Sun Sep 20 05:31:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 1367784 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 4BvGT96vHvz9sT6 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=hP7NUk3H7Un+IMAsgeQ7rgs0i0LhEQCFcvCFNK51Isk=; b=hmDTStIbuOI8f2KZ+Sj3Yqkk3q fNEvYmkLFUi0E0PUqUw2Q1vvHA/PexmHR4Z5B0ngK/s2fS1/ZWxmVvvKxB8kj0dUajHSDLodY58kE ytXF3ncBrA/dKa77nlNp1GJRqiGv6XLk1i1lAo/oPSSWNlQLw2O/of71F26+nI7K2B2OW+LYp8PT2 BOKnxcfMFjrph8cgLvALS1wuqtujZgfF5rQUVGtrLZp0BP5RN6hjO0jYJWmbkd59OamSi//lvXu5S sY/YxHUdxwfRFhbs3N3kDTs4jJQlEQinPtwgkaeHnJ4Rlf5/U0splAww9EE28BmmZhvejDh6YXYFG MccPGy5w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kJrx1-0004N5-9k; Sun, 20 Sep 2020 05:31:51 +0000 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kJrww-0004Lg-Gj for openwrt-devel@lists.openwrt.org; Sun, 20 Sep 2020 05:31:47 +0000 Received: by mail-pl1-x643.google.com with SMTP id bd2so5193275plb.7 for ; Sat, 19 Sep 2020 22:31:44 -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=E8dVCxhmBYruUz8P65PPHoYLp56JWX4QzBNGh0rpjUA=; b=ttYVHMpZAaRKHzqrRgfwcBPOE51Yj6wbTHlNSM22qtAVVoIuvTFbmJ5KN7y42b2p6y /+18iov1KLs7hVGArFP7mdYBm2OnzZgd/oWqIm+lDIPDaT9MdMWX/KlvC1BO1xGGtzti Y2UcXDQu8t3WeWY6TXrLcTWcm3CaiL/poWm30ClAkREPjvMNM2WAePiTb9zCGAkMNX0m tO44ueQPWra5Qj90HY5E+FGe9oHP0DHt1+VFx9DAI2mw+nWB8TAZzuZIoW+tLLXCPTul uUa4L8O6m2O5MuLAPeTuybbWp5Xg0xVm77k+W7OlLJOVA+xYfnZavM3Z7IMKt+85gIFJ Qfww== 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=E8dVCxhmBYruUz8P65PPHoYLp56JWX4QzBNGh0rpjUA=; b=WjxVNnykbQM5ANNb2qTmAVV3hDojukvatRuUSnRY1Gd8trTFaGpairlKXJY1mYuOqH Lpe4VGwmdIJMr/C2EOUE3SCz0tBtRhswHt+brRKjwdCZbfn/SGLQ6tA4L87rpXHMTV+j 2jCzloADJ09CDeyR7bGeaQNNSKatHTwKYV83qmaGgG0PViJLsf7I0wYcipsyYe1VwNPR dRgqJOJ6KkT53c6mhKpvs0nsgV27/tbR0VqViUiVhPkpaOJGJpq9J1fdnodiRPR/uji6 ynnVrVaCJll9QdkoCjVcXUuOE3d1vi+7lL/K1tPmj37foWjZwsSH1439DolAxunFFs5e 15Zw== X-Gm-Message-State: AOAM5301RX57WJMCLm1GXBK3wy+Frc996+Y30CuyGaLpbsVa9UFc5qhf OQKL2PZPDA8kF/Gn0I6EvgEk3nLlprE8jA== X-Google-Smtp-Source: ABdhPJw7kniICUd6I9Cyt3bWEKdYP7LSq3MDWSrnucJ8AlV595fXId5bvAGfv7jBgaMlo2c4Ph+pWA== X-Received: by 2002:a17:902:b186:b029:d1:cc21:9a7d with SMTP id s6-20020a170902b186b02900d1cc219a7dmr27753953plr.8.1600579903179; Sat, 19 Sep 2020 22:31:43 -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.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Sep 2020 22:31:42 -0700 (PDT) From: Rosen Penev To: openwrt-devel@lists.openwrt.org Subject: [PATCH 2/4] base-files/functions.sh: do not iterate over ls Date: Sat, 19 Sep 2020 22:31:38 -0700 Message-Id: <20200920053140.35255-2-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_013146_579209_DFC5DFA5 X-CRM114-Status: GOOD ( 13.71 ) 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:643 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 From https://github.com/koalaman/shellcheck/wiki/SC2045 : When looping over a set of files, it's always better to use globs when possible. Using command expansion causes word splitting and glob expansion, which will cause problems for certain filenames (typically first seen when trying to process a file with spaces in the name). Signed-off-by: Rosen Penev --- package/base-files/files/lib/functions.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh index 59bb0fe711..0f56387244 100755 --- a/package/base-files/files/lib/functions.sh +++ b/package/base-files/files/lib/functions.sh @@ -290,8 +290,9 @@ default_postinst() { include() { local file - for file in $(ls $1/*.sh 2>/dev/null); do - . $file + for file in "$1"/*.sh; do + [ -e "$file" ] || break + . "$file" done }