treewide: replace which
with command -v
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 <mail@aparcar.org>
This commit is contained in:
parent
416dccf72a
commit
30ea917518
11 changed files with 28 additions and 28 deletions
|
@ -12,7 +12,7 @@ PKG_NAME:=ddns-scripts
|
||||||
PKG_VERSION:=2.7.8
|
PKG_VERSION:=2.7.8
|
||||||
# Release == build
|
# Release == build
|
||||||
# increase on changes of services files or tld_names.dat
|
# increase on changes of services files or tld_names.dat
|
||||||
PKG_RELEASE:=21
|
PKG_RELEASE:=22
|
||||||
|
|
||||||
PKG_LICENSE:=GPL-2.0
|
PKG_LICENSE:=GPL-2.0
|
||||||
PKG_MAINTAINER:=
|
PKG_MAINTAINER:=
|
||||||
|
|
|
@ -33,7 +33,7 @@ timer2dhms() {
|
||||||
|
|
||||||
# using function to not confuse function calls with existing ones inside /lib/functions.sh
|
# using function to not confuse function calls with existing ones inside /lib/functions.sh
|
||||||
update_config() {
|
update_config() {
|
||||||
uc_uci="$(which uci) -q" # ignore errors
|
uc_uci="$(command -v uci) -q" # ignore errors
|
||||||
uc_cfg=""
|
uc_cfg=""
|
||||||
uc_name=""
|
uc_name=""
|
||||||
uc_var=""
|
uc_var=""
|
||||||
|
|
|
@ -73,23 +73,23 @@ DNS_CHARSET="[@a-zA-Z0-9._-]"
|
||||||
LUCI_HELPER=$(printf %s "$MYPROG" | grep -i "luci")
|
LUCI_HELPER=$(printf %s "$MYPROG" | grep -i "luci")
|
||||||
|
|
||||||
# Name Server Lookup Programs
|
# Name Server Lookup Programs
|
||||||
BIND_HOST=$(which host)
|
BIND_HOST=$(command -v host)
|
||||||
KNOT_HOST=$(which khost)
|
KNOT_HOST=$(command -v khost)
|
||||||
DRILL=$(which drill)
|
DRILL=$(command -v drill)
|
||||||
HOSTIP=$(which hostip)
|
HOSTIP=$(command -v hostip)
|
||||||
NSLOOKUP=$(which nslookup)
|
NSLOOKUP=$(command -v nslookup)
|
||||||
|
|
||||||
# Transfer Programs
|
# Transfer Programs
|
||||||
WGET=$(which wget)
|
WGET=$(command -v wget)
|
||||||
WGET_SSL=$(which wget-ssl)
|
WGET_SSL=$(command -v wget-ssl)
|
||||||
|
|
||||||
CURL=$(which curl)
|
CURL=$(command -v curl)
|
||||||
# CURL_SSL not empty then SSL support available
|
# CURL_SSL not empty then SSL support available
|
||||||
CURL_SSL=$($CURL -V 2>/dev/null | grep -F "https")
|
CURL_SSL=$($CURL -V 2>/dev/null | grep -F "https")
|
||||||
# CURL_PROXY not empty then Proxy support available
|
# CURL_PROXY not empty then Proxy support available
|
||||||
CURL_PROXY=$(find /lib /usr/lib -name libcurl.so* -exec strings {} 2>/dev/null \; | grep -im1 "all_proxy")
|
CURL_PROXY=$(find /lib /usr/lib -name libcurl.so* -exec strings {} 2>/dev/null \; | grep -im1 "all_proxy")
|
||||||
|
|
||||||
UCLIENT_FETCH=$(which uclient-fetch)
|
UCLIENT_FETCH=$(command -v uclient-fetch)
|
||||||
|
|
||||||
# Global configuration settings
|
# Global configuration settings
|
||||||
# allow NON-public IP's
|
# allow NON-public IP's
|
||||||
|
@ -491,8 +491,8 @@ sanitize_variable() {
|
||||||
verify_host_port() {
|
verify_host_port() {
|
||||||
local __HOST=$1
|
local __HOST=$1
|
||||||
local __PORT=$2
|
local __PORT=$2
|
||||||
local __NC=$(which nc)
|
local __NC=$(command -v nc)
|
||||||
local __NCEXT=$($(which nc) --help 2>&1 | grep "\-w" 2>/dev/null) # busybox nc compiled with extensions
|
local __NCEXT=$($(command -v nc) --help 2>&1 | grep "\-w" 2>/dev/null) # busybox nc compiled with extensions
|
||||||
local __IP __IPV4 __IPV6 __RUNPROG __PROG __ERR
|
local __IP __IPV4 __IPV6 __RUNPROG __PROG __ERR
|
||||||
# return codes
|
# return codes
|
||||||
# 1 system specific error
|
# 1 system specific error
|
||||||
|
@ -921,7 +921,7 @@ get_local_ip () {
|
||||||
[ -n "$__DATA" ] && write_log 7 "Local IP '$__DATA' detected on network '$ip_network'"
|
[ -n "$__DATA" ] && write_log 7 "Local IP '$__DATA' detected on network '$ip_network'"
|
||||||
elif [ -n "$ip_interface" -a "$ip_source" = "interface" ]; then
|
elif [ -n "$ip_interface" -a "$ip_source" = "interface" ]; then
|
||||||
local __DATA4=""; local __DATA6=""
|
local __DATA4=""; local __DATA6=""
|
||||||
if [ -n "$(which ip)" ]; then # ip program installed
|
if [ -n "$(command -v ip)" ]; then # ip program installed
|
||||||
write_log 7 "#> ip -o addr show dev $ip_interface scope global >$DATFILE 2>$ERRFILE"
|
write_log 7 "#> ip -o addr show dev $ip_interface scope global >$DATFILE 2>$ERRFILE"
|
||||||
ip -o addr show dev $ip_interface scope global >$DATFILE 2>$ERRFILE
|
ip -o addr show dev $ip_interface scope global >$DATFILE 2>$ERRFILE
|
||||||
__ERR=$?
|
__ERR=$?
|
||||||
|
@ -1124,7 +1124,7 @@ get_registered_ip() {
|
||||||
__RUNPROG="$__PROG $lookup_host >$DATFILE 2>$ERRFILE"
|
__RUNPROG="$__PROG $lookup_host >$DATFILE 2>$ERRFILE"
|
||||||
__PROG="hostip"
|
__PROG="hostip"
|
||||||
elif [ -n "$NSLOOKUP" ]; then # last use BusyBox nslookup
|
elif [ -n "$NSLOOKUP" ]; then # last use BusyBox nslookup
|
||||||
NSLOOKUP_MUSL=$($(which nslookup) localhost 2>&1 | grep -F "(null)") # not empty busybox compiled with musl
|
NSLOOKUP_MUSL=$($(command -v nslookup) localhost 2>&1 | grep -F "(null)") # not empty busybox compiled with musl
|
||||||
[ $force_dnstcp -ne 0 ] && \
|
[ $force_dnstcp -ne 0 ] && \
|
||||||
write_log 14 "Busybox nslookup - no support for 'DNS over TCP'"
|
write_log 14 "Busybox nslookup - no support for 'DNS over TCP'"
|
||||||
[ -n "$NSLOOKUP_MUSL" -a -n "$dns_server" ] && \
|
[ -n "$NSLOOKUP_MUSL" -a -n "$dns_server" ] && \
|
||||||
|
|
|
@ -5,7 +5,7 @@ local __URL="https://freedns.42.pl/xmlrpc.php"
|
||||||
[ -z "$username" ] && write_log 14 "Service section not configured correctly! Missing 'username'"
|
[ -z "$username" ] && write_log 14 "Service section not configured correctly! Missing 'username'"
|
||||||
[ -z "$password" ] && write_log 14 "Service section not configured correctly! Missing 'password'"
|
[ -z "$password" ] && write_log 14 "Service section not configured correctly! Missing 'password'"
|
||||||
[ $ip_dynamic -eq 1 ] && __IP='\<dynamic\>'
|
[ $ip_dynamic -eq 1 ] && __IP='\<dynamic\>'
|
||||||
PROG="$(which curl) -sk"
|
PROG="$(command -v curl) -sk"
|
||||||
write_log 7 "sending update to freedns.42.pl with ip $__IP"
|
write_log 7 "sending update to freedns.42.pl with ip $__IP"
|
||||||
XMLDATA="<?xml version='1.0'?><methodCall><methodName>xname.updateArecord</methodName><params><param><value><struct><member><name>name</name><value><string>[RECORDNAME]</string></value></member><member><name>zone</name><value><string>[ZONENAME]</string></value></member><member><name>oldaddress</name><value><string>*</string></value></member><member><name>updatereverse</name><value><string>0</string></value></member><member><name>user</name><value><string>[USERNAME]</string></value></member><member><name>ttl</name><value><string>600</string></value></member><member><name>newaddress</name><value><string>[IP]</string></value></member><member><name>password</name><value><string>[PASSWORD]</string></value></member></struct></value></param></params></methodCall>"
|
XMLDATA="<?xml version='1.0'?><methodCall><methodName>xname.updateArecord</methodName><params><param><value><struct><member><name>name</name><value><string>[RECORDNAME]</string></value></member><member><name>zone</name><value><string>[ZONENAME]</string></value></member><member><name>oldaddress</name><value><string>*</string></value></member><member><name>updatereverse</name><value><string>0</string></value></member><member><name>user</name><value><string>[USERNAME]</string></value></member><member><name>ttl</name><value><string>600</string></value></member><member><name>newaddress</name><value><string>[IP]</string></value></member><member><name>password</name><value><string>[PASSWORD]</string></value></member></struct></value></param></params></methodCall>"
|
||||||
XMLDATA=$(echo $XMLDATA | sed -e "s#\[USERNAME\]#$URL_USER#g" -e "s#\[PASSWORD\]#$URL_PASS#g" \
|
XMLDATA=$(echo $XMLDATA | sed -e "s#\[USERNAME\]#$URL_USER#g" -e "s#\[PASSWORD\]#$URL_PASS#g" \
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
#
|
#
|
||||||
local __TTL=600 #.preset DNS TTL (in seconds)
|
local __TTL=600 #.preset DNS TTL (in seconds)
|
||||||
local __RRTYPE __PW __TCP
|
local __RRTYPE __PW __TCP
|
||||||
local __PROG=$(which nsupdate) # BIND nsupdate ?
|
local __PROG=$(command -v nsupdate) # BIND nsupdate ?
|
||||||
[ -z "$__PROG" ] && __PROG=$(which knsupdate) # Knot nsupdate ?
|
[ -z "$__PROG" ] && __PROG=$(command -v knsupdate) # Knot nsupdate ?
|
||||||
|
|
||||||
[ -z "$__PROG" ] && write_log 14 "'nsupdate' or 'knsupdate' not installed !"
|
[ -z "$__PROG" ] && write_log 14 "'nsupdate' or 'knsupdate' not installed !"
|
||||||
[ -z "$username" ] && write_log 14 "Service section not configured correctly! Missing 'username'"
|
[ -z "$username" ] && write_log 14 "Service section not configured correctly! Missing 'username'"
|
||||||
|
|
|
@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=mwan3
|
PKG_NAME:=mwan3
|
||||||
PKG_VERSION:=2.8.12
|
PKG_VERSION:=2.8.12
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=2
|
||||||
PKG_MAINTAINER:=Florian Eckert <fe@dev.tdt.de>
|
PKG_MAINTAINER:=Florian Eckert <fe@dev.tdt.de>
|
||||||
PKG_LICENSE:=GPL-2.0
|
PKG_LICENSE:=GPL-2.0
|
||||||
|
|
||||||
|
|
|
@ -23,19 +23,19 @@ if_down() {
|
||||||
validate_track_method() {
|
validate_track_method() {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
ping)
|
ping)
|
||||||
which ping 1>/dev/null 2>&1 || {
|
command -v ping 1>/dev/null 2>&1 || {
|
||||||
$LOG warn "Missing ping. Please install iputils-ping package or enable ping util and recompile busybox."
|
$LOG warn "Missing ping. Please install iputils-ping package or enable ping util and recompile busybox."
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
;;
|
;;
|
||||||
arping)
|
arping)
|
||||||
which arping 1>/dev/null 2>&1 || {
|
command -v arping 1>/dev/null 2>&1 || {
|
||||||
$LOG warn "Missing arping. Please install iputils-arping package."
|
$LOG warn "Missing arping. Please install iputils-arping package."
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
;;
|
;;
|
||||||
httping)
|
httping)
|
||||||
which httping 1>/dev/null 2>&1 || {
|
command -v httping 1>/dev/null 2>&1 || {
|
||||||
$LOG warn "Missing httping. Please install httping package."
|
$LOG warn "Missing httping. Please install httping package."
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ validate_track_method() {
|
||||||
}
|
}
|
||||||
;;
|
;;
|
||||||
nping-*)
|
nping-*)
|
||||||
which nping 1>/dev/null 2>&1 || {
|
command -v nping 1>/dev/null 2>&1 || {
|
||||||
$LOG warn "Missing nping. Please install nping package."
|
$LOG warn "Missing nping. Please install nping package."
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=trafficshaper
|
PKG_NAME:=trafficshaper
|
||||||
PKG_VERSION:=1.0.0
|
PKG_VERSION:=1.0.0
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=2
|
||||||
PKG_MAINTAINER:=Luiz Angelo Daros de Luca <luizluca@gmail.com>
|
PKG_MAINTAINER:=Luiz Angelo Daros de Luca <luizluca@gmail.com>
|
||||||
|
|
||||||
PKG_LICENSE:=GPL-2.0-or-later
|
PKG_LICENSE:=GPL-2.0-or-later
|
||||||
|
|
|
@ -64,11 +64,11 @@ requires() {
|
||||||
die 2 "cannot load $module. Please install kmod-$module"
|
die 2 "cannot load $module. Please install kmod-$module"
|
||||||
done
|
done
|
||||||
for cmd in $REQ_CMDS; do
|
for cmd in $REQ_CMDS; do
|
||||||
which $cmd &>/dev/null ||
|
command -v $cmd &>/dev/null ||
|
||||||
die 2 "cannot find command $cmd. Please install $cmd"
|
die 2 "cannot find command $cmd. Please install $cmd"
|
||||||
done
|
done
|
||||||
|
|
||||||
if ! which ip6tables &>/dev/null; then
|
if ! command -v ip6tables &>/dev/null; then
|
||||||
v "Disabling IPv6 as ip6tables was not found"
|
v "Disabling IPv6 as ip6tables was not found"
|
||||||
IP6T=true
|
IP6T=true
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=lxc
|
PKG_NAME:=lxc
|
||||||
PKG_VERSION:=4.0.2
|
PKG_VERSION:=4.0.2
|
||||||
PKG_RELEASE:=3
|
PKG_RELEASE:=4
|
||||||
|
|
||||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||||
PKG_SOURCE_URL:=https://linuxcontainers.org/downloads/lxc/
|
PKG_SOURCE_URL:=https://linuxcontainers.org/downloads/lxc/
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
+: ${ZGREP:=zgrep}
|
+: ${ZGREP:=zgrep}
|
||||||
+: ${GUNZIP:=gunzip}
|
+: ${GUNZIP:=gunzip}
|
||||||
+
|
+
|
||||||
+if [ -z $(which $ZGREP) ] && ! [ -z $(which $GUNZIP) ] && [ -x $(which $GUNZIP) ] && [ -f $CONFIG ] && [ "$CONFIG" == "/proc/config.gz" ] ; then
|
+if [ -z $(command -v $ZGREP) ] && ! [ -z $(command -v $GUNZIP) ] && [ -x $(command -v $GUNZIP) ] && [ -f $CONFIG ] && [ "$CONFIG" == "/proc/config.gz" ] ; then
|
||||||
+
|
+
|
||||||
+ CONFIG_NEW="/tmp/config-$(uname -r)"
|
+ CONFIG_NEW="/tmp/config-$(uname -r)"
|
||||||
+ $GUNZIP -c $CONFIG > $CONFIG_NEW
|
+ $GUNZIP -c $CONFIG > $CONFIG_NEW
|
||||||
|
|
Loading…
Reference in a new issue