command -v is now required by POSIX, type is technically an extension.
}
if [ "$ifwireless" = "1" ] && \
- type wpa_supplicant >/dev/null 2>&1 && \
- type wpa_cli >/dev/null 2>&1
+ command -v wpa_supplicant >/dev/null 2>&1 && \
+ command -v wpa_cli >/dev/null 2>&1
then
case "$reason" in
PREINIT) wpa_supplicant_start;;
NL="
"
: ${resolvconf:=resolvconf}
-if type "$resolvconf" >/dev/null 2>&1; then
+if command -v "$resolvconf" >/dev/null 2>&1; then
have_resolvconf=true
else
have_resolvconf=false
{
[ -z "$new_ip_address" ] && return 1
# Silly ISC programs love to send error text to stdout
- if type dig >/dev/null 2>&1; then
+ if command -v dig >/dev/null 2>&1; then
h=$(dig +short -x $new_ip_address)
if [ $? = 0 ]; then
echo "$h" | sed 's/\.$//'
return 0
fi
- elif type host >/dev/null 2>&1; then
+ elif command -v host >/dev/null 2>&1; then
h=$(host $new_ip_address)
if [ $? = 0 ]; then
echo "$h" \
| sed 's/.* domain name pointer \(.*\)./\1/'
return 0
fi
- elif type getent >/dev/null 2>&1; then
+ elif command -v getent >/dev/null 2>&1; then
h=$(getent hosts $new_ip_address)
if [ $? = 0 ]; then
echo "$h" | sed 's/[^ ]* *\([^ ]*\).*/\1/'
if [ -z "${1+x}" ]; then
if [ -r /proc/sys/kernel/hostname ]; then
read name </proc/sys/kernel/hostname && echo "$name"
- elif type hostname >/dev/null 2>/dev/null; then
+ elif command -v hostname >/dev/null 2>/dev/null; then
hostname
elif sysctl kern.hostname >/dev/null 2>&1; then
sysctl -n kern.hostname
if [ -w /proc/sys/kernel/hostname ]; then
echo "$1" >/proc/sys/kernel/hostname
- elif [ -n "$1" ] && type hostname >/dev/null 2>&1; then
+ elif [ -n "$1" ] && command -v hostname >/dev/null 2>&1; then
hostname "$1"
elif sysctl kern.hostname >/dev/null 2>&1; then
sysctl -w "kern.hostname=$1" >/dev/null
# Debian has a separate file for DHCP config to avoid stamping on
# the master.
-if [ "$ntp_service" = ntpd ] && type invoke-rc.d >/dev/null 2>&1; then
+if [ "$ntp_service" = ntpd ] && command -v invoke-rc.d >/dev/null 2>&1; then
[ -e /var/lib/ntp ] || mkdir /var/lib/ntp
: ${ntp_service:=ntp}
: ${NTP_DHCP_CONF:=/var/lib/ntp/ntp.conf.dhcp}
key="$1"
shift
- if type sed >/dev/null 2>&1; then
+ if command -v sed >/dev/null 2>&1; then
sed -n "s/^$key//p" $@
else
for x do
in_marker=0
shift; shift
- if type sed >/dev/null 2>&1; then
+ if command -v sed >/dev/null 2>&1; then
sed "/^$m1/,/^$m2/d" $@
else
for x do
{
[ -e "$1" ] && [ -e "$2" ] || return 1
- if type cmp >/dev/null 2>&1; then
+ if command -v cmp >/dev/null 2>&1; then
cmp -s "$1" "$2"
- elif type diff >/dev/null 2>&1; then
+ elif command -v diff >/dev/null 2>&1; then
diff -q "$1" "$2" >/dev/null
else
# Hopefully we're only working on small text files ...
err|error) echo "$interface: $*" >&2;;
*) echo "$interface: $*";;
esac
- if type logger >/dev/null 2>&1; then
+ if command -v logger >/dev/null 2>&1; then
logger -i -p daemon."$lvl" -t dhcpcd-run-hooks "$interface: $*"
fi
}