aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2011-11-10 21:46:08 -0500
committerMike Frysinger <vapier@gentoo.org>2011-11-19 02:25:36 -0500
commitef1ff1b4f29762d1caf83dc2b65ccfc7cb96e140 (patch)
treef1ebb65eec6eb156a0fba737bcd5386af2a9ebfe /net
parent0510c473d4cd9097401e3a7bc236b0121977b81d (diff)
make shell math operations style more succulent
Convert the style: var=$((${var} + 1)) to: : $(( var += 1 )) The latter is easier to read imo. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'net')
-rw-r--r--net/apipa.sh8
-rw-r--r--net/arping.sh2
-rw-r--r--net/clip.sh2
-rw-r--r--net/ifconfig.sh.BSD.in4
-rw-r--r--net/ifconfig.sh.Linux.in26
-rw-r--r--net/ifplugd.sh2
-rw-r--r--net/ip6to4.sh4
-rw-r--r--net/iproute2.sh6
-rw-r--r--net/iwconfig.sh.BSD.in32
-rw-r--r--net/iwconfig.sh.Linux.in30
-rw-r--r--net/netplugd.sh2
-rw-r--r--net/pppd.sh2
-rw-r--r--net/tuntap.sh2
-rw-r--r--net/wpa_supplicant.sh2
14 files changed, 62 insertions, 62 deletions
diff --git a/net/apipa.sh b/net/apipa.sh
index 3163104d..ae61233b 100644
--- a/net/apipa.sh
+++ b/net/apipa.sh
@@ -26,20 +26,20 @@ apipa_start()
eindent
while [ ${i} -lt 64516 ]; do
- i1=$((($(_random) % 255) + 1))
- i2=$((($(_random) % 255) + 1))
+ : $(( i1 = (_random % 255) + 1 ))
+ : $(( i2 = (_random % 255) + 1 ))
addr="169.254.${i1}.${i2}"
vebegin "${addr}/16"
if ! arping_address "${addr}"; then
eval config_${config_index}="\"${addr}/16 broadcast 169.254.255.255\""
- config_index=$((${config_index} - 1))
+ : $(( config_index -= 1 ))
veend 0
eoutdent
return 0
fi
- i=$((${i} + 1))
+ : $(( i += 1 ))
done
eerror "No free address found!"
diff --git a/net/arping.sh b/net/arping.sh
index b77d70c1..83360d78 100644
--- a/net/arping.sh
+++ b/net/arping.sh
@@ -34,7 +34,7 @@ arping_address()
while [ ${w} -gt 0 -a -z "${foundmac}" ]; do
foundmac="$(arping2 ${opts} -r -c 1 -i "${IFACE}" "${ip}" 2>/dev/null | \
sed -e 'y/abcdef/ABCDEF/')"
- w=$((${w} - 1))
+ : $(( w -= 1 ))
done
else
[ -z "$(_get_inet_address)" ] && opts="${opts} -D"
diff --git a/net/clip.sh b/net/clip.sh
index 35efa3f5..2fc290f4 100644
--- a/net/clip.sh
+++ b/net/clip.sh
@@ -148,7 +148,7 @@ clip_post_start()
local nleftretries=10 emsg= ecode=
while [ ${nleftretries} -gt 0 ]; do
- nleftretries=$((${nleftretries} - 1))
+ : $(( nleftretries -= 1 ))
emsg="$(atmarp -s "${peerip}" "${ifvpivci}" "$@" 2>&1)"
ecode=$? && break
sleep 2
diff --git a/net/ifconfig.sh.BSD.in b/net/ifconfig.sh.BSD.in
index c0c75f08..15c8fb8e 100644
--- a/net/ifconfig.sh.BSD.in
+++ b/net/ifconfig.sh.BSD.in
@@ -38,7 +38,7 @@ _ifindex()
echo "${x#/dev/net}"
return 0
fi
- i=$((${i} + 1))
+ : $(( i += 1 ))
done
;;
default)
@@ -47,7 +47,7 @@ _ifindex()
echo "${i}"
return 0
fi
- i=$((${i} + 1))
+ : $(( i += 1 ))
done
;;
esac
diff --git a/net/ifconfig.sh.Linux.in b/net/ifconfig.sh.Linux.in
index a5540c03..dcbd6286 100644
--- a/net/ifconfig.sh.Linux.in
+++ b/net/ifconfig.sh.Linux.in
@@ -26,7 +26,7 @@ _ifindex()
{
local line= i=-2
while read line; do
- i=$((${i} + 1))
+ : $(( i += 1 ))
[ ${i} -lt 1 ] && continue
case "${line}" in
"${IFACE}:"*) echo "${i}"; return 0;;
@@ -34,7 +34,7 @@ _ifindex()
done < /proc/net/dev
# Return the next available index
- i=$((${i} + 1))
+ : $(( i += 1 ))
echo "${i}"
return 1
}
@@ -96,7 +96,7 @@ _get_inet_addresses()
_exists || break
local addr="$(_get_inet_address)"
[ -n "${addr}" ] && addrs="${addrs}${addrs:+ }${addr}"
- i=$((${i} + 1))
+ : $(( i += 1 ))
done
echo "${addrs}"
}
@@ -106,26 +106,26 @@ _cidr2netmask()
local cidr="$1" netmask="" done=0 i=0 sum=0 cur=128
local octets= frac=
- local octets=$((${cidr} / 8))
- local frac=$((${cidr} % 8))
+ local octets=$(( cidr / 8 ))
+ local frac=$(( cidr % 8 ))
while [ ${octets} -gt 0 ]; do
netmask="${netmask}.255"
- octets=$((${octets} - 1))
- done=$((${done} + 1))
+ : $(( octets -= 1 ))
+ : $(( done += 1 ))
done
if [ ${done} -lt 4 ]; then
while [ ${i} -lt ${frac} ]; do
- sum=$((${sum} + ${cur}))
- cur=$((${cur} / 2))
- i=$((${i} + 1))
+ : $(( sum += cur ))
+ : $(( cur /= 2 ))
+ : $(( i += 1 ))
done
netmask="${netmask}.${sum}"
- done=$((${done} + 1))
+ : $(( done += 1 ))
while [ ${done} -lt 4 ]; do
netmask="${netmask}.0"
- done=$((${done} + 1))
+ : $(( done += 1 ))
done
fi
@@ -150,7 +150,7 @@ _add_address()
# Get the last alias made for the interface and add 1 to it
i=$(ifconfig | sed '1!G;h;$!d' | grep -m 1 -o "^${iface}:[0-9]*" \
| sed -n -e 's/'"${iface}"'://p')
- i=$((${i:-0} + 1))
+ : $(( i = ${i:-0} + 1 ))
iface="${iface}:${i}"
fi
diff --git a/net/ifplugd.sh b/net/ifplugd.sh
index d048b61a..0bcde2f3 100644
--- a/net/ifplugd.sh
+++ b/net/ifplugd.sh
@@ -72,7 +72,7 @@ ifplugd_pre_start()
fi
sleep 1
[ ${timeout} -eq 0 ] && continue
- i=$((${i} + 1))
+ : $(( i += 1 ))
[ ${i} -ge ${timeout} ] && break
done
diff --git a/net/ip6to4.sh b/net/ip6to4.sh
index 0e94293f..45644507 100644
--- a/net/ip6to4.sh
+++ b/net/ip6to4.sh
@@ -51,7 +51,7 @@ ip6to4_start()
case "${ip}" in
172.${i}.*) break;;
esac
- i=$((${i} + 1))
+ : $(( i += 1 ))
done
[ ${i} -lt 32 ] && continue
;;
@@ -90,7 +90,7 @@ ip6to4_start()
# Now apply our config
eval config_${config_index}=\'"${new}"\'
- config_index=$((${config_index} - 1))
+ : $(( config_index -= 1 ))
# Add a route for us, ensuring we don't delete anything else
local routes="$(_get_array "routes_${IFVAR}")
diff --git a/net/iproute2.sh b/net/iproute2.sh
index 660d5147..91282ea6 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -36,7 +36,7 @@ _ifindex()
{
local line= i=-2
while read line; do
- i=$((${i} + 1))
+ : $(( i += 1 ))
[ ${i} -lt 1 ] && continue
case "${line}" in
"${IFACE}:"*) echo "${i}"; return 0;;
@@ -44,7 +44,7 @@ _ifindex()
done < /proc/net/dev
# Return the next available index
- i=$((${i} + 1))
+ : $(( i += 1 ))
echo "${i}"
return 1
}
@@ -290,7 +290,7 @@ iproute2_post_start()
while [ $n -ge 0 ]; do
_iproute2_ipv6_tentative || break
sleep 1
- n=$(($n - 1))
+ : $(( n -= 1 ))
done
[ $n -ge 0 ]
eend $?
diff --git a/net/iwconfig.sh.BSD.in b/net/iwconfig.sh.BSD.in
index 850d70b2..3acaf663 100644
--- a/net/iwconfig.sh.BSD.in
+++ b/net/iwconfig.sh.BSD.in
@@ -218,7 +218,7 @@ iwconfig_associate()
sleep 1
[ ${timeout} -eq 0 ] && continue
- i=$((${i} + 1))
+ : $(( i += 1 ))
[ ${i} -ge ${timeout} ] && { eend 1; return 1; }
done
@@ -252,13 +252,13 @@ iwconfig_scan()
scan="$(LC_ALL=C ifconfig -v "${IFACE}" list scan 2>/dev/null | sed -e "1 d" -e "s/$/'/g" -e "s/^/'/g")"
while [ ${i} -lt 3 -a -z "${scan}" ] ; do
scan="${scan}${scan:+ }$(LC_ALL=C ifconfig -v "${IFACE}" scan 2>/dev/null | sed -e "1 d" -e "s/$/'/g" -e "s/^/'/g")"
- i=$((${i} + 1))
+ : $(( i += 1 ))
done
APS=-1
eval set -- ${scan}
for line in "$@" ; do
- APS=$((${APS} + 1))
+ : $(( APS += 1 ))
set -- ${line}
while true ; do
case "$1" in
@@ -276,7 +276,7 @@ iwconfig_scan()
# Add 1000 for managed nodes as we prefer them to adhoc
set -- $*
case "$1" in
- *E*) eval QUAL_${APS}=$((${quality} + 1000)) ;;
+ *E*) eval QUAL_${APS}=$(( quality + 1000 )) ;;
*) eval QUAL_${APS}=\$quality ;;
esac
done
@@ -290,7 +290,7 @@ iwconfig_scan()
# Sort based on quality
local i=0 k=1 a= b= x= t=
while [ ${i} -lt ${APS} ] ; do
- k=$((${i} + 1))
+ : $(( k = i + 1 ))
while [ ${k} -le ${APS} ] ; do
eval a=\$QUALITY_${i}
[ -z "${a}" ] && break
@@ -302,15 +302,15 @@ iwconfig_scan()
eval ${x}_${k}=\$t
done
fi
- k=$((${k} + 1))
+ : $(( k += 1 ))
done
- i=$((${i} + 1))
+ : $(( i += 1 ))
done
# Strip any duplicates
local i=0 k=1 a= b=
while [ ${i} -lt ${APS} ] ; do
- k=$((${i} + 1))
+ : $(( k = i + 1 ))
while [ ${k} -le ${APS} ] ; do
eval a=\$MAC_${i}
eval b=\$MAC_${k}
@@ -327,9 +327,9 @@ iwconfig_scan()
unset MAC_${k} SSID_${k} CHAN_${k} QUALITY_${k} CAPS_${k}
fi
fi
- k=$((${k} + 1))
+ : $(( k += 1 ))
done
- i=$((${i} + 1))
+ : $(( i += 1 ))
done
local i=0 e= m= s=
@@ -337,7 +337,7 @@ iwconfig_scan()
while [ ${i} -le ${APS} ] ; do
eval x=\$MAC_${i}
if [ -z "${x}" ] ; then
- i=$((${i} + 1))
+ : $(( i += 1 ))
continue
fi
@@ -374,7 +374,7 @@ iwconfig_scan()
unset SSID_${i} MAC_${i} CHAN_${i} QUALITY_${i} CAPS_${i}
fi
done
- i=$((${i} + 1))
+ : $(( i += 1 ))
done
eoutdent
return 0
@@ -396,7 +396,7 @@ iwconfig_force_preferred()
found_AP=true
break
fi
- i=$((${i} + 1))
+ : $(( i += 1 ))
done
if ! ${found_AP} ; then
SSID=${ssid}
@@ -428,7 +428,7 @@ iwconfig_connect_preferred()
iwconfig_associate "${mac}" \
"${chan}" "${caps}" && return 0
fi
- i=$((${i} + 1))
+ : $(( i += 1 ))
done
done
@@ -442,7 +442,7 @@ iwconfig_connect_not_preferred()
while [ ${i} -le ${APS} ] ; do
eval e=\$SSID_${i}
if [ -z "${e}" ] ; then
- i=$((${i} + 1))
+ : $(( i += 1 ))
continue
fi
@@ -465,7 +465,7 @@ iwconfig_connect_not_preferred()
iwconfig_associate "${mac}" \
"${chan}" "${caps}" && return 0
fi
- i=$((${i} + 1))
+ : $(( i += 1 ))
done
return 1
diff --git a/net/iwconfig.sh.Linux.in b/net/iwconfig.sh.Linux.in
index 199678f5..293bc1f3 100644
--- a/net/iwconfig.sh.Linux.in
+++ b/net/iwconfig.sh.Linux.in
@@ -39,7 +39,7 @@ _get_ssid()
return 0
fi
sleep 1
- i=$((${i} - 1))
+ : $(( i -= 1 ))
done
return 1
@@ -229,7 +229,7 @@ iwconfig_wait_for_association()
sleep 1
[ ${timeout} -eq 0 ] && continue
- i=$((${i} + 1))
+ : $(( i += 1 ))
[ ${i} -ge ${timeout} ] && return 1
done
return 1
@@ -347,7 +347,7 @@ iwconfig_scan()
;;
esac
fi
- i=$((${i} + 1))
+ : $(( i += 1 ))
done
if [ -z "${scan}" ]; then
@@ -377,7 +377,7 @@ iwconfig_scan()
for line; do
case "${line}" in
*Address:*)
- APS=$((${APS} + 1))
+ : $(( APS += 1 ))
eval MAC_${APS}="\""$(echo "${line#*: }" | tr '[:lower:]' '[:upper:]')"\""
eval QUALITY_${APS}=0
;;
@@ -427,7 +427,7 @@ iwconfig_scan()
# Sort based on quality
local i=0 k=1 a= b= x= t=
while [ ${i} -lt ${APS} ]; do
- k=$((${i} + 1))
+ : $(( k = i + 1 ))
while [ ${k} -le ${APS} ]; do
eval a=\$QUALITY_${i}
[ -z "${a}" ] && break
@@ -439,15 +439,15 @@ iwconfig_scan()
eval ${x}_${k}=\$t
done
fi
- k=$((${k} + 1))
+ : $(( k += 1 ))
done
- i=$((${i} + 1))
+ : $(( i += 1 ))
done
# Strip any duplicates
local i=0 k=1 a= b=
while [ ${i} -lt ${APS} ]; do
- k=$((${i} + 1))
+ : $(( k = i + 1 ))
while [ ${k} -le ${APS} ]; do
eval a=\$MAC_${i}
eval b=\$MAC_${k}
@@ -459,9 +459,9 @@ iwconfig_scan()
[ -n "${a}" -a -n "${b}" ] && [ "${a}" -lt "${b}" ] && u=${i}
unset MAC_${u} SSID_${u} MODE_${u} CHAN_${u} QUALITY_${u} ENC_${u}
fi
- k=$((${k} + 1))
+ : $(( k += 1 ))
done
- i=$((${i} + 1))
+ : $(( i += 1 ))
done
local i=0 e= m= s=
@@ -469,7 +469,7 @@ iwconfig_scan()
while [ ${i} -le ${APS} ]; do
eval x=\$MAC_${i}
if [ -z "${x}" ]; then
- i=$((${i} + 1))
+ : $(( i += 1 ))
continue
fi
@@ -506,7 +506,7 @@ iwconfig_scan()
unset SSID_${i} MAC_${i} ${MODE}_${i} CHAN_${i} QUALITY_${i} ENC_${i}
fi
done
- i=$((${i} + 1))
+ : $(( i += 1 ))
done
eoutdent
}
@@ -526,7 +526,7 @@ iwconfig_force_preferred()
found_AP=true
break
fi
- i=$((${i} + 1))
+ : $(( i += 1 ))
done
if ! ${found_AP}; then
SSID=${ssid}
@@ -559,7 +559,7 @@ iwconfig_connect_preferred()
iwconfig_associate "${mode}" "${mac}" "${enc}" "${freq}" \
"${chan}" && return 0
fi
- i=$((${i} + 1))
+ : $(( i += 1 ))
done
done
@@ -593,7 +593,7 @@ iwconfig_connect_not_preferred()
"${chan}" && return 0
fi
fi
- i=$((${i} + 1))
+ : $(( i += 1 ))
done
return 1
diff --git a/net/netplugd.sh b/net/netplugd.sh
index f7df7a39..f43a5e64 100644
--- a/net/netplugd.sh
+++ b/net/netplugd.sh
@@ -74,7 +74,7 @@ netplugd_pre_start()
fi
sleep 1
[ ${timeout} -eq 0 ] && continue
- i=$((${i} + 1))
+ : $(( i += 1 ))
[ ${i} -ge ${timeout} ] && break
done
diff --git a/net/pppd.sh b/net/pppd.sh
index 1f9d302e..97bd3ee5 100644
--- a/net/pppd.sh
+++ b/net/pppd.sh
@@ -96,7 +96,7 @@ pppd_pre_start()
if ! ${hasdefaultmetric}; then
local m=
eval m=\$metric_${IFVAR}
- [ -z "${m}" ] && m=$((${metric} + $(_ifindex)))
+ [ -z "${m}" ] && : $(( m = metric + $(_ifindex) ))
opts="${opts} defaultmetric ${m}"
fi
if [ -n "${mtu}" ]; then
diff --git a/net/tuntap.sh b/net/tuntap.sh
index 884e0ab7..ac505abb 100644
--- a/net/tuntap.sh
+++ b/net/tuntap.sh
@@ -30,7 +30,7 @@ tuntap_pre_start()
local timeout=10
while [ ! -e /dev/net/tun -a ${timeout} -gt 0 ]; do
sleep 1
- timeout=$((${timeout} - 1))
+ : $(( timeout -= 1 ))
done
if [ ! -e /dev/net/tun ]; then
eerror "TUN/TAP support present but /dev/net/tun is not"
diff --git a/net/wpa_supplicant.sh b/net/wpa_supplicant.sh
index 91de49ef..53b0256c 100644
--- a/net/wpa_supplicant.sh
+++ b/net/wpa_supplicant.sh
@@ -34,7 +34,7 @@ _get_ssid()
return 0
fi
sleep 1
- timeout=$((timeout - 1))
+ : $(( timeout -= 1 ))
done
return 1