From patchwork Fri Aug 7 22:54:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Spooren X-Patchwork-Id: 1342426 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=none (p=none dis=none) header.from=aparcar.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=L4XPGWtI; dkim-atps=neutral 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 4BNghb3pBSz9sPC for ; Sat, 8 Aug 2020 08:56:31 +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:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=cBlHyfZoQzc/yBq18fCFJJcB+QUV/WSa7KHOwt86Kss=; b=L4XPGWtIfwxXXQIF4th8MbUBYu c1M1eimwLwHXj917qLtwjXr4g4NJ3Vj3fC5EVE5wuScyt+EDwaYvChx1YZxfcQea1nOw9LqrKQPWD MbE4Xv76paqGNpQzmKl7JiYZw36W+PZqxhuqYLo2ry6tb7dlW1lJ3+2zvz0i19sJcJb8gJb8OotWG ZuhkWvmeotW/ytkUqEEfZy2qRzQMrDYyo8ih9pBajARsO0KJOODI5SKfC7Hp3ORikIpvtG7b0f777 tYPbmkk/+X6JbCqOYVSKqzGhiHa0rZTIkCp1OK1CKmQ9H4hM1/+bZd45Du0+c2BUWslS3qcgjmZab qjwnb6lw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k4BGN-0001YD-52; Fri, 07 Aug 2020 22:54:59 +0000 Received: from relay12.mail.gandi.net ([217.70.178.232]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k4BGI-0001Xo-Iy for openwrt-devel@lists.openwrt.org; Fri, 07 Aug 2020 22:54:56 +0000 Received: from dawn.lan (udp224251uds.hawaiiantel.net [72.234.141.215]) (Authenticated sender: mail@aparcar.org) by relay12.mail.gandi.net (Postfix) with ESMTPA id E8F8D200003; Fri, 7 Aug 2020 22:54:50 +0000 (UTC) From: Paul Spooren To: openwrt-devel@lists.openwrt.org Subject: [PATCH] treewide: replace `which` with `command -v` Date: Fri, 7 Aug 2020 12:54:46 -1000 Message-Id: <20200807225446.1414145-1-mail@aparcar.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200807_185454_846380_96D6FDCF X-CRM114-Status: GOOD ( 10.10 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [217.70.178.232 listed in wl.mailspike.net] -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [217.70.178.232 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 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: , Cc: Paul Spooren Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Fix shellcheck SC2230 > which is non-standard. Use builtin 'command -v' instead. Once applied to everything concerning OpenWrt we can disable the busybox feature `which` and save 3.8kB. Signed-off-by: Paul Spooren Acked-by: Stijn Tintel --- include/rootfs.mk | 6 +++--- package/base-files/files/lib/upgrade/stage2 | 2 +- .../kernel/broadcom-wl/files/lib/wifi/broadcom.sh | 2 +- scripts/ipkg-build | 12 ++++++------ 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/rootfs.mk b/include/rootfs.mk index b6775c7e15..18ada3cd43 100644 --- a/include/rootfs.mk +++ b/include/rootfs.mk @@ -69,7 +69,7 @@ define prepare_rootfs @( \ cd $(1); \ for script in ./usr/lib/opkg/info/*.postinst; do \ - IPKG_INSTROOT=$(1) $$(which bash) $$script; \ + IPKG_INSTROOT=$(1) $$(command -v bash) $$script; \ ret=$$?; \ if [ $$ret -ne 0 ]; then \ echo "postinst script $$script has failed with exit code $$ret" >&2; \ @@ -79,10 +79,10 @@ define prepare_rootfs for script in ./etc/init.d/*; do \ grep '#!/bin/sh /etc/rc.common' $$script >/dev/null || continue; \ if ! echo " $(3) " | grep -q " $$(basename $$script) "; then \ - IPKG_INSTROOT=$(1) $$(which bash) ./etc/rc.common $$script enable; \ + IPKG_INSTROOT=$(1) $$(command -v bash) ./etc/rc.common $$script enable; \ echo "Enabling" $$(basename $$script); \ else \ - IPKG_INSTROOT=$(1) $$(which bash) ./etc/rc.common $$script disable; \ + IPKG_INSTROOT=$(1) $$(command -v bash) ./etc/rc.common $$script disable; \ echo "Disabling" $$(basename $$script); \ fi; \ done || true \ diff --git a/package/base-files/files/lib/upgrade/stage2 b/package/base-files/files/lib/upgrade/stage2 index dbb33e8958..a4fef42134 100755 --- a/package/base-files/files/lib/upgrade/stage2 +++ b/package/base-files/files/lib/upgrade/stage2 @@ -45,7 +45,7 @@ switch_to_ramfs() { snapshot snapshot_tool \ $RAMFS_COPY_BIN do - local file="$(which "$binary" 2>/dev/null)" + local file="$(command -v "$binary" 2>/dev/null)" [ -n "$file" ] && install_bin "$file" done install_file /etc/resolv.conf /lib/*.sh /lib/functions/*.sh /lib/upgrade/*.sh /lib/upgrade/do_stage2 /usr/share/libubox/jshn.sh $RAMFS_COPY_DATA diff --git a/package/kernel/broadcom-wl/files/lib/wifi/broadcom.sh b/package/kernel/broadcom-wl/files/lib/wifi/broadcom.sh index 33447341b2..352c365f27 100644 --- a/package/kernel/broadcom-wl/files/lib/wifi/broadcom.sh +++ b/package/kernel/broadcom-wl/files/lib/wifi/broadcom.sh @@ -223,7 +223,7 @@ enable_broadcom() { } local _c=0 - local nas="$(which nas)" + local nas="$(command -v nas)" local if_pre_up if_up nas_cmd local vif vif_pre_up vif_post_up vif_do_up vif_txpower local bssmax=$(wlc ifname "$device" bssmax) diff --git a/scripts/ipkg-build b/scripts/ipkg-build index 21127f3391..6e027bc546 100755 --- a/scripts/ipkg-build +++ b/scripts/ipkg-build @@ -10,10 +10,10 @@ set -e version=1.0 -FIND="$(which find)" -FIND="${FIND:-$(which gfind)}" -TAR="${TAR:-$(which tar)}" -GZIP="$(which gzip)" +FIND="$(command -v find)" +FIND="${FIND:-$(command -v gfind)}" +TAR="${TAR:-$(command -v tar)}" +GZIP="$(command -v gzip)" # try to use fixed source epoch if [ -n "$SOURCE_DATE_EPOCH" ]; then @@ -21,10 +21,10 @@ if [ -n "$SOURCE_DATE_EPOCH" ]; then # look up date of last commit elif [ -d "$TOPDIR/.git" ]; then - GIT="$(which git)" + GIT="$(command -v git)" TIMESTAMP=$(cd $TOPDIR; $GIT log -1 -s --format=%ci) elif [ -d "$TOPDIR/.svn" ]; then - SVN="$(which svn)" + SVN="$(command -v svn)" TIMESTAMP=$($SVN info "$TOPDIR" | sed -n "s/^Last Changed Date: \(.*\)/\1/p") else TIMESTAMP=$(date)