diff mbox series

[OpenWrt-Devel,PATCHv2] base-files/functions.sh: use command -v instead of which

Message ID 20200117223819.23058-1-rosenp@gmail.com
State Accepted
Delegated to: Petr Štetiar
Headers show
Series [OpenWrt-Devel,PATCHv2] base-files/functions.sh: use command -v instead of which | expand

Commit Message

Rosen Penev Jan. 17, 2020, 10:38 p.m. UTC
which must be executed. command -v is a shell builtin.

https://github.com/koalaman/shellcheck/wiki/SC2230

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 v2: enclose command -v in $().
 package/base-files/files/lib/functions.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh
index 207fe96ce6..bc67e65edc 100755
--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -176,7 +176,7 @@  default_prerm() {
 		ret=$?
 	fi
 
-	local shell="$(which bash)"
+	local shell="$(command -v bash)"
 	for i in $(grep -s "^/etc/init.d/" "$root/usr/lib/opkg/info/${pkgname}.list"); do
 		if [ -n "$root" ]; then
 			${shell:-/bin/sh} "$root/etc/rc.common" "$root$i" disable
@@ -265,7 +265,7 @@  default_postinst() {
 		rm -f /tmp/luci-indexcache
 	fi
 
-	local shell="$(which bash)"
+	local shell="$(command -v bash)"
 	for i in $(grep -s "^/etc/init.d/" "$root$filelist"); do
 		if [ -n "$root" ]; then
 			${shell:-/bin/sh} "$root/etc/rc.common" "$root$i" enable