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>
This commit is contained in:
Mike Frysinger 2011-11-10 21:46:08 -05:00
parent 0510c473d4
commit ef1ff1b4f2
32 changed files with 98 additions and 98 deletions

View File

@ -49,7 +49,7 @@ start()
retval=1 retval=1
break break
fi fi
x=$(($x + 1)) : $(( x += 1 ))
done done
eend $retval eend $retval

View File

@ -85,7 +85,7 @@ start()
if [ -e /etc/adjtime ] && yesno $clock_adjfile; then if [ -e /etc/adjtime ] && yesno $clock_adjfile; then
_hwclock --adjust $utc_cmd _hwclock --adjust $utc_cmd
retval=$(($retval + $?)) : $(( retval += $? ))
fi fi
# If setting UTC, don't bother to run hwclock when first booting # If setting UTC, don't bother to run hwclock when first booting
@ -99,7 +99,7 @@ start()
else else
_hwclock --systz $utc_cmd $clock_args _hwclock --systz $utc_cmd $clock_args
fi fi
retval=$(($retval + $?)) : $(( retval += $? ))
fi fi
eend $retval "Failed to set the system clock" eend $retval "Failed to set the system clock"

View File

@ -47,7 +47,7 @@ start()
n=1 n=1
while [ $n -le $ttyn ]; do while [ $n -le $ttyn ]; do
kbd_mode $kmode -C $ttydev$n kbd_mode $kmode -C $ttydev$n
n=$(($n + 1)) : $(( n += 1 ))
done done
eend 0 eend 0

View File

@ -21,7 +21,7 @@ restore()
mixer -f "$mixer" \ mixer -f "$mixer" \
$(cat "/var/db/${mixer#/dev/}-state") >/dev/null $(cat "/var/db/${mixer#/dev/}-state") >/dev/null
veend $? veend $?
: $((retval += $?)) : $(( retval += $? ))
fi fi
done done
} }
@ -40,7 +40,7 @@ stop()
vebegin "$mixer" vebegin "$mixer"
mixer -f "$mixer" -s >/var/db/"${mixer#/dev/}"-state mixer -f "$mixer" -s >/var/db/"${mixer#/dev/}"-state
veend $? veend $?
: $((retval += $?)) : $(( retval += $? ))
done done
eoutdent eoutdent
eend $retval eend $retval

View File

@ -57,7 +57,7 @@ start()
[ -z "$args" ] && eval args=\$module_${aa}_args [ -z "$args" ] && eval args=\$module_${aa}_args
[ -z "$args" ] && eval args=\$module_${xx}_args [ -z "$args" ] && eval args=\$module_${xx}_args
eval modprobe -q "$mpargs" "$x" "$args" eval modprobe -q "$mpargs" "$x" "$args"
eend $? "Failed to load $x" && cnt=$(($cnt + 1)) eend $? "Failed to load $x" && : $(( cnt += 1 ))
done done
einfo "Autoloaded $cnt module(s)" einfo "Autoloaded $cnt module(s)"
} }

View File

@ -54,7 +54,7 @@ start()
local ttyv= local ttyv=
for ttyv in /dev/ttyv*; do for ttyv in /dev/ttyv*; do
vidcontrol < "$ttyv" -m on vidcontrol < "$ttyv" -m on
: $((retval+= $?)) : $(( retval += $? ))
done done
fi fi

View File

@ -115,7 +115,7 @@ _wait_for_carrier()
eend 0 eend 0
return 0 return 0
fi fi
timeout=$((${timeout} - 1)) : $(( timeout -= 1 ))
[ "${efunc}" = "einfon" ] && printf "." [ "${efunc}" = "einfon" ] && printf "."
done done
@ -144,9 +144,9 @@ _netmask2cidr()
local i= len= local i= len=
local IFS=. local IFS=.
for i in $1; do for i in $1; do
while [ ${i} != "0" ]; do while [ i -ne 0 ]; do
len=$((${len} + ${i} % 2)) : $(( len += i % 2 ))
i=$((${i} >> 1)) : $(( i >>= 1 ))
done done
done done
@ -277,7 +277,7 @@ _gen_module_list()
echo "module_${i}_program_start='${PROGRAM_START}'" >> "${MODULESLIST}" echo "module_${i}_program_start='${PROGRAM_START}'" >> "${MODULESLIST}"
echo "module_${i}_program_stop='${PROGRAM_STOP}'" >> "${MODULESLIST}" echo "module_${i}_program_stop='${PROGRAM_STOP}'" >> "${MODULESLIST}"
echo "module_${i}_provide='${PROVIDE}'" >> "${MODULESLIST}" echo "module_${i}_provide='${PROVIDE}'" >> "${MODULESLIST}"
i=$((${i} + 1)) : $(( i += 1 ))
done done
echo "module_${i}=" >> "${MODULESLIST}" echo "module_${i}=" >> "${MODULESLIST}"
) )
@ -304,7 +304,7 @@ _load_modules()
local i=-1 x= mod= f= provides= local i=-1 x= mod= f= provides=
while true; do while true; do
i=$((${i} + 1)) : $(( i += 1 ))
eval mod=\$module_${i} eval mod=\$module_${i}
[ -z "${mod}" ] && break [ -z "${mod}" ] && break
[ -e "${MODULESDIR}/${mod}.sh" ] || continue [ -e "${MODULESDIR}/${mod}.sh" ] || continue
@ -438,7 +438,7 @@ _load_config()
# so modules can influence it # so modules can influence it
for cmd; do for cmd; do
eval config_${config_index}="'${cmd}'" eval config_${config_index}="'${cmd}'"
config_index=$((${config_index} + 1)) : $(( config_index += 1 ))
done done
# Terminate the list # Terminate the list
eval config_${config_index}= eval config_${config_index}=
@ -446,7 +446,7 @@ _load_config()
config_index=0 config_index=0
for cmd in ${fallback}; do for cmd in ${fallback}; do
eval fallback_${config_index}="'${cmd}'" eval fallback_${config_index}="'${cmd}'"
config_index=$((${config_index} + 1)) : $(( config_index += 1 ))
done done
# Terminate the list # Terminate the list
eval fallback_${config_index}= eval fallback_${config_index}=
@ -541,7 +541,7 @@ start()
if [ -n "${our_metric}" ]; then if [ -n "${our_metric}" ]; then
metric=${our_metric} metric=${our_metric}
elif [ "${IFACE}" != "lo" -a "${IFACE}" != "lo0" ]; then elif [ "${IFACE}" != "lo" -a "${IFACE}" != "lo0" ]; then
metric=$((${metric} + $(_ifindex))) : $(( metric += $(_ifindex) ))
fi fi
while true; do while true; do
@ -581,11 +581,11 @@ start()
eindent eindent
eval config_${config_index}=\$config eval config_${config_index}=\$config
unset fallback_${config_index} unset fallback_${config_index}
config_index=$((${config_index} - 1)) : $(( config_index -= 1 ))
fi fi
fi fi
eoutdent eoutdent
config_index=$((${config_index} + 1)) : $(( config_index += 1 ))
done done
if ! ${oneworked}; then if ! ${oneworked}; then

View File

@ -287,7 +287,7 @@ start()
tentative || break tentative || break
[ $r = 5 ] && vebegin "Waiting for tentative addresses" [ $r = 5 ] && vebegin "Waiting for tentative addresses"
sleep 1 sleep 1
r=$(($r - 1)) : $(( r -= 1 ))
done done
if [ $r != 5 ]; then if [ $r != 5 ]; then
[ $r != 0 ] [ $r != 0 ]

View File

@ -21,7 +21,7 @@ _setleds()
while [ $i -le $ttyn ]; do while [ $i -le $ttyn ]; do
setleds -D "$1"num < $dev$i || retval=1 setleds -D "$1"num < $dev$i || retval=1
i=$(($i + 1)) : $(( i += 1 ))
done done
return $retval return $retval

View File

@ -33,7 +33,7 @@ start()
# Good to go! # Good to go!
"$svc" start && started="$started $svc" "$svc" start && started="$started $svc"
: $((retval += $?)) : $(( retval += $? ))
done done
service_set_value started "$started" service_set_value started "$started"
eend $retval "Some local rc services failed to start" eend $retval "Some local rc services failed to start"
@ -46,7 +46,7 @@ stop()
local svc= retval=0 local svc= retval=0
for svc in $(rcorder $(service_get_value started) 2>/dev/null | sort -r); do for svc in $(rcorder $(service_get_value started) 2>/dev/null | sort -r); do
"$svc" stop "$svc" stop
: $((retval += $?)) : $(( retval += $? ))
done done
eend $retval "Some local rc services failed to stop" eend $retval "Some local rc services failed to stop"
return 0 return 0

View File

@ -31,7 +31,7 @@ start()
n=1 n=1
while [ ${n} -le "$ttyn" ]; do while [ ${n} -le "$ttyn" ]; do
printf "\033%s" "$termencoding" >$ttydev$n printf "\033%s" "$termencoding" >$ttydev$n
n=$(($n + 1)) : $(( n += 1 ))
done done
# Save the encoding for use immediately at boot # Save the encoding for use immediately at boot

View File

@ -16,7 +16,7 @@ save_seed()
local psz=1 local psz=1
if [ -e /proc/sys/kernel/random/poolsize ]; then if [ -e /proc/sys/kernel/random/poolsize ]; then
psz=$(($(cat /proc/sys/kernel/random/poolsize) / 4096)) : $(( psz = $(cat /proc/sys/kernel/random/poolsize) / 4096 ))
fi fi
( # sub shell to prevent umask pollution ( # sub shell to prevent umask pollution

View File

@ -449,7 +449,7 @@ eat()
veinfo "Eating `basename ${food}`" veinfo "Eating `basename ${food}`"
${command} --eat ${food} ${command} --eat ${food}
retval=$? retval=$?
: $((${result} += ${retval})) : $(( result += retval ))
[ ${retval} = 0 ] && ate="${ate} `basename ${food}`" [ ${retval} = 0 ] && ate="${ate} `basename ${food}`"
done done

View File

@ -26,20 +26,20 @@ apipa_start()
eindent eindent
while [ ${i} -lt 64516 ]; do while [ ${i} -lt 64516 ]; do
i1=$((($(_random) % 255) + 1)) : $(( i1 = (_random % 255) + 1 ))
i2=$((($(_random) % 255) + 1)) : $(( i2 = (_random % 255) + 1 ))
addr="169.254.${i1}.${i2}" addr="169.254.${i1}.${i2}"
vebegin "${addr}/16" vebegin "${addr}/16"
if ! arping_address "${addr}"; then if ! arping_address "${addr}"; then
eval config_${config_index}="\"${addr}/16 broadcast 169.254.255.255\"" eval config_${config_index}="\"${addr}/16 broadcast 169.254.255.255\""
config_index=$((${config_index} - 1)) : $(( config_index -= 1 ))
veend 0 veend 0
eoutdent eoutdent
return 0 return 0
fi fi
i=$((${i} + 1)) : $(( i += 1 ))
done done
eerror "No free address found!" eerror "No free address found!"

View File

@ -34,7 +34,7 @@ arping_address()
while [ ${w} -gt 0 -a -z "${foundmac}" ]; do while [ ${w} -gt 0 -a -z "${foundmac}" ]; do
foundmac="$(arping2 ${opts} -r -c 1 -i "${IFACE}" "${ip}" 2>/dev/null | \ foundmac="$(arping2 ${opts} -r -c 1 -i "${IFACE}" "${ip}" 2>/dev/null | \
sed -e 'y/abcdef/ABCDEF/')" sed -e 'y/abcdef/ABCDEF/')"
w=$((${w} - 1)) : $(( w -= 1 ))
done done
else else
[ -z "$(_get_inet_address)" ] && opts="${opts} -D" [ -z "$(_get_inet_address)" ] && opts="${opts} -D"

View File

@ -148,7 +148,7 @@ clip_post_start()
local nleftretries=10 emsg= ecode= local nleftretries=10 emsg= ecode=
while [ ${nleftretries} -gt 0 ]; do while [ ${nleftretries} -gt 0 ]; do
nleftretries=$((${nleftretries} - 1)) : $(( nleftretries -= 1 ))
emsg="$(atmarp -s "${peerip}" "${ifvpivci}" "$@" 2>&1)" emsg="$(atmarp -s "${peerip}" "${ifvpivci}" "$@" 2>&1)"
ecode=$? && break ecode=$? && break
sleep 2 sleep 2

View File

@ -38,7 +38,7 @@ _ifindex()
echo "${x#/dev/net}" echo "${x#/dev/net}"
return 0 return 0
fi fi
i=$((${i} + 1)) : $(( i += 1 ))
done done
;; ;;
default) default)
@ -47,7 +47,7 @@ _ifindex()
echo "${i}" echo "${i}"
return 0 return 0
fi fi
i=$((${i} + 1)) : $(( i += 1 ))
done done
;; ;;
esac esac

View File

@ -26,7 +26,7 @@ _ifindex()
{ {
local line= i=-2 local line= i=-2
while read line; do while read line; do
i=$((${i} + 1)) : $(( i += 1 ))
[ ${i} -lt 1 ] && continue [ ${i} -lt 1 ] && continue
case "${line}" in case "${line}" in
"${IFACE}:"*) echo "${i}"; return 0;; "${IFACE}:"*) echo "${i}"; return 0;;
@ -34,7 +34,7 @@ _ifindex()
done < /proc/net/dev done < /proc/net/dev
# Return the next available index # Return the next available index
i=$((${i} + 1)) : $(( i += 1 ))
echo "${i}" echo "${i}"
return 1 return 1
} }
@ -96,7 +96,7 @@ _get_inet_addresses()
_exists || break _exists || break
local addr="$(_get_inet_address)" local addr="$(_get_inet_address)"
[ -n "${addr}" ] && addrs="${addrs}${addrs:+ }${addr}" [ -n "${addr}" ] && addrs="${addrs}${addrs:+ }${addr}"
i=$((${i} + 1)) : $(( i += 1 ))
done done
echo "${addrs}" echo "${addrs}"
} }
@ -106,26 +106,26 @@ _cidr2netmask()
local cidr="$1" netmask="" done=0 i=0 sum=0 cur=128 local cidr="$1" netmask="" done=0 i=0 sum=0 cur=128
local octets= frac= local octets= frac=
local octets=$((${cidr} / 8)) local octets=$(( cidr / 8 ))
local frac=$((${cidr} % 8)) local frac=$(( cidr % 8 ))
while [ ${octets} -gt 0 ]; do while [ ${octets} -gt 0 ]; do
netmask="${netmask}.255" netmask="${netmask}.255"
octets=$((${octets} - 1)) : $(( octets -= 1 ))
done=$((${done} + 1)) : $(( done += 1 ))
done done
if [ ${done} -lt 4 ]; then if [ ${done} -lt 4 ]; then
while [ ${i} -lt ${frac} ]; do while [ ${i} -lt ${frac} ]; do
sum=$((${sum} + ${cur})) : $(( sum += cur ))
cur=$((${cur} / 2)) : $(( cur /= 2 ))
i=$((${i} + 1)) : $(( i += 1 ))
done done
netmask="${netmask}.${sum}" netmask="${netmask}.${sum}"
done=$((${done} + 1)) : $(( done += 1 ))
while [ ${done} -lt 4 ]; do while [ ${done} -lt 4 ]; do
netmask="${netmask}.0" netmask="${netmask}.0"
done=$((${done} + 1)) : $(( done += 1 ))
done done
fi fi
@ -150,7 +150,7 @@ _add_address()
# Get the last alias made for the interface and add 1 to it # 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]*" \ i=$(ifconfig | sed '1!G;h;$!d' | grep -m 1 -o "^${iface}:[0-9]*" \
| sed -n -e 's/'"${iface}"'://p') | sed -n -e 's/'"${iface}"'://p')
i=$((${i:-0} + 1)) : $(( i = ${i:-0} + 1 ))
iface="${iface}:${i}" iface="${iface}:${i}"
fi fi

View File

@ -72,7 +72,7 @@ ifplugd_pre_start()
fi fi
sleep 1 sleep 1
[ ${timeout} -eq 0 ] && continue [ ${timeout} -eq 0 ] && continue
i=$((${i} + 1)) : $(( i += 1 ))
[ ${i} -ge ${timeout} ] && break [ ${i} -ge ${timeout} ] && break
done done

View File

@ -51,7 +51,7 @@ ip6to4_start()
case "${ip}" in case "${ip}" in
172.${i}.*) break;; 172.${i}.*) break;;
esac esac
i=$((${i} + 1)) : $(( i += 1 ))
done done
[ ${i} -lt 32 ] && continue [ ${i} -lt 32 ] && continue
;; ;;
@ -90,7 +90,7 @@ ip6to4_start()
# Now apply our config # Now apply our config
eval config_${config_index}=\'"${new}"\' 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 # Add a route for us, ensuring we don't delete anything else
local routes="$(_get_array "routes_${IFVAR}") local routes="$(_get_array "routes_${IFVAR}")

View File

@ -36,7 +36,7 @@ _ifindex()
{ {
local line= i=-2 local line= i=-2
while read line; do while read line; do
i=$((${i} + 1)) : $(( i += 1 ))
[ ${i} -lt 1 ] && continue [ ${i} -lt 1 ] && continue
case "${line}" in case "${line}" in
"${IFACE}:"*) echo "${i}"; return 0;; "${IFACE}:"*) echo "${i}"; return 0;;
@ -44,7 +44,7 @@ _ifindex()
done < /proc/net/dev done < /proc/net/dev
# Return the next available index # Return the next available index
i=$((${i} + 1)) : $(( i += 1 ))
echo "${i}" echo "${i}"
return 1 return 1
} }
@ -290,7 +290,7 @@ iproute2_post_start()
while [ $n -ge 0 ]; do while [ $n -ge 0 ]; do
_iproute2_ipv6_tentative || break _iproute2_ipv6_tentative || break
sleep 1 sleep 1
n=$(($n - 1)) : $(( n -= 1 ))
done done
[ $n -ge 0 ] [ $n -ge 0 ]
eend $? eend $?

View File

@ -218,7 +218,7 @@ iwconfig_associate()
sleep 1 sleep 1
[ ${timeout} -eq 0 ] && continue [ ${timeout} -eq 0 ] && continue
i=$((${i} + 1)) : $(( i += 1 ))
[ ${i} -ge ${timeout} ] && { eend 1; return 1; } [ ${i} -ge ${timeout} ] && { eend 1; return 1; }
done 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")" 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 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")" 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 done
APS=-1 APS=-1
eval set -- ${scan} eval set -- ${scan}
for line in "$@" ; do for line in "$@" ; do
APS=$((${APS} + 1)) : $(( APS += 1 ))
set -- ${line} set -- ${line}
while true ; do while true ; do
case "$1" in case "$1" in
@ -276,7 +276,7 @@ iwconfig_scan()
# Add 1000 for managed nodes as we prefer them to adhoc # Add 1000 for managed nodes as we prefer them to adhoc
set -- $* set -- $*
case "$1" in case "$1" in
*E*) eval QUAL_${APS}=$((${quality} + 1000)) ;; *E*) eval QUAL_${APS}=$(( quality + 1000 )) ;;
*) eval QUAL_${APS}=\$quality ;; *) eval QUAL_${APS}=\$quality ;;
esac esac
done done
@ -290,7 +290,7 @@ iwconfig_scan()
# Sort based on quality # Sort based on quality
local i=0 k=1 a= b= x= t= local i=0 k=1 a= b= x= t=
while [ ${i} -lt ${APS} ] ; do while [ ${i} -lt ${APS} ] ; do
k=$((${i} + 1)) : $(( k = i + 1 ))
while [ ${k} -le ${APS} ] ; do while [ ${k} -le ${APS} ] ; do
eval a=\$QUALITY_${i} eval a=\$QUALITY_${i}
[ -z "${a}" ] && break [ -z "${a}" ] && break
@ -302,15 +302,15 @@ iwconfig_scan()
eval ${x}_${k}=\$t eval ${x}_${k}=\$t
done done
fi fi
k=$((${k} + 1)) : $(( k += 1 ))
done done
i=$((${i} + 1)) : $(( i += 1 ))
done done
# Strip any duplicates # Strip any duplicates
local i=0 k=1 a= b= local i=0 k=1 a= b=
while [ ${i} -lt ${APS} ] ; do while [ ${i} -lt ${APS} ] ; do
k=$((${i} + 1)) : $(( k = i + 1 ))
while [ ${k} -le ${APS} ] ; do while [ ${k} -le ${APS} ] ; do
eval a=\$MAC_${i} eval a=\$MAC_${i}
eval b=\$MAC_${k} eval b=\$MAC_${k}
@ -327,9 +327,9 @@ iwconfig_scan()
unset MAC_${k} SSID_${k} CHAN_${k} QUALITY_${k} CAPS_${k} unset MAC_${k} SSID_${k} CHAN_${k} QUALITY_${k} CAPS_${k}
fi fi
fi fi
k=$((${k} + 1)) : $(( k += 1 ))
done done
i=$((${i} + 1)) : $(( i += 1 ))
done done
local i=0 e= m= s= local i=0 e= m= s=
@ -337,7 +337,7 @@ iwconfig_scan()
while [ ${i} -le ${APS} ] ; do while [ ${i} -le ${APS} ] ; do
eval x=\$MAC_${i} eval x=\$MAC_${i}
if [ -z "${x}" ] ; then if [ -z "${x}" ] ; then
i=$((${i} + 1)) : $(( i += 1 ))
continue continue
fi fi
@ -374,7 +374,7 @@ iwconfig_scan()
unset SSID_${i} MAC_${i} CHAN_${i} QUALITY_${i} CAPS_${i} unset SSID_${i} MAC_${i} CHAN_${i} QUALITY_${i} CAPS_${i}
fi fi
done done
i=$((${i} + 1)) : $(( i += 1 ))
done done
eoutdent eoutdent
return 0 return 0
@ -396,7 +396,7 @@ iwconfig_force_preferred()
found_AP=true found_AP=true
break break
fi fi
i=$((${i} + 1)) : $(( i += 1 ))
done done
if ! ${found_AP} ; then if ! ${found_AP} ; then
SSID=${ssid} SSID=${ssid}
@ -428,7 +428,7 @@ iwconfig_connect_preferred()
iwconfig_associate "${mac}" \ iwconfig_associate "${mac}" \
"${chan}" "${caps}" && return 0 "${chan}" "${caps}" && return 0
fi fi
i=$((${i} + 1)) : $(( i += 1 ))
done done
done done
@ -442,7 +442,7 @@ iwconfig_connect_not_preferred()
while [ ${i} -le ${APS} ] ; do while [ ${i} -le ${APS} ] ; do
eval e=\$SSID_${i} eval e=\$SSID_${i}
if [ -z "${e}" ] ; then if [ -z "${e}" ] ; then
i=$((${i} + 1)) : $(( i += 1 ))
continue continue
fi fi
@ -465,7 +465,7 @@ iwconfig_connect_not_preferred()
iwconfig_associate "${mac}" \ iwconfig_associate "${mac}" \
"${chan}" "${caps}" && return 0 "${chan}" "${caps}" && return 0
fi fi
i=$((${i} + 1)) : $(( i += 1 ))
done done
return 1 return 1

View File

@ -39,7 +39,7 @@ _get_ssid()
return 0 return 0
fi fi
sleep 1 sleep 1
i=$((${i} - 1)) : $(( i -= 1 ))
done done
return 1 return 1
@ -229,7 +229,7 @@ iwconfig_wait_for_association()
sleep 1 sleep 1
[ ${timeout} -eq 0 ] && continue [ ${timeout} -eq 0 ] && continue
i=$((${i} + 1)) : $(( i += 1 ))
[ ${i} -ge ${timeout} ] && return 1 [ ${i} -ge ${timeout} ] && return 1
done done
return 1 return 1
@ -347,7 +347,7 @@ iwconfig_scan()
;; ;;
esac esac
fi fi
i=$((${i} + 1)) : $(( i += 1 ))
done done
if [ -z "${scan}" ]; then if [ -z "${scan}" ]; then
@ -377,7 +377,7 @@ iwconfig_scan()
for line; do for line; do
case "${line}" in case "${line}" in
*Address:*) *Address:*)
APS=$((${APS} + 1)) : $(( APS += 1 ))
eval MAC_${APS}="\""$(echo "${line#*: }" | tr '[:lower:]' '[:upper:]')"\"" eval MAC_${APS}="\""$(echo "${line#*: }" | tr '[:lower:]' '[:upper:]')"\""
eval QUALITY_${APS}=0 eval QUALITY_${APS}=0
;; ;;
@ -427,7 +427,7 @@ iwconfig_scan()
# Sort based on quality # Sort based on quality
local i=0 k=1 a= b= x= t= local i=0 k=1 a= b= x= t=
while [ ${i} -lt ${APS} ]; do while [ ${i} -lt ${APS} ]; do
k=$((${i} + 1)) : $(( k = i + 1 ))
while [ ${k} -le ${APS} ]; do while [ ${k} -le ${APS} ]; do
eval a=\$QUALITY_${i} eval a=\$QUALITY_${i}
[ -z "${a}" ] && break [ -z "${a}" ] && break
@ -439,15 +439,15 @@ iwconfig_scan()
eval ${x}_${k}=\$t eval ${x}_${k}=\$t
done done
fi fi
k=$((${k} + 1)) : $(( k += 1 ))
done done
i=$((${i} + 1)) : $(( i += 1 ))
done done
# Strip any duplicates # Strip any duplicates
local i=0 k=1 a= b= local i=0 k=1 a= b=
while [ ${i} -lt ${APS} ]; do while [ ${i} -lt ${APS} ]; do
k=$((${i} + 1)) : $(( k = i + 1 ))
while [ ${k} -le ${APS} ]; do while [ ${k} -le ${APS} ]; do
eval a=\$MAC_${i} eval a=\$MAC_${i}
eval b=\$MAC_${k} eval b=\$MAC_${k}
@ -459,9 +459,9 @@ iwconfig_scan()
[ -n "${a}" -a -n "${b}" ] && [ "${a}" -lt "${b}" ] && u=${i} [ -n "${a}" -a -n "${b}" ] && [ "${a}" -lt "${b}" ] && u=${i}
unset MAC_${u} SSID_${u} MODE_${u} CHAN_${u} QUALITY_${u} ENC_${u} unset MAC_${u} SSID_${u} MODE_${u} CHAN_${u} QUALITY_${u} ENC_${u}
fi fi
k=$((${k} + 1)) : $(( k += 1 ))
done done
i=$((${i} + 1)) : $(( i += 1 ))
done done
local i=0 e= m= s= local i=0 e= m= s=
@ -469,7 +469,7 @@ iwconfig_scan()
while [ ${i} -le ${APS} ]; do while [ ${i} -le ${APS} ]; do
eval x=\$MAC_${i} eval x=\$MAC_${i}
if [ -z "${x}" ]; then if [ -z "${x}" ]; then
i=$((${i} + 1)) : $(( i += 1 ))
continue continue
fi fi
@ -506,7 +506,7 @@ iwconfig_scan()
unset SSID_${i} MAC_${i} ${MODE}_${i} CHAN_${i} QUALITY_${i} ENC_${i} unset SSID_${i} MAC_${i} ${MODE}_${i} CHAN_${i} QUALITY_${i} ENC_${i}
fi fi
done done
i=$((${i} + 1)) : $(( i += 1 ))
done done
eoutdent eoutdent
} }
@ -526,7 +526,7 @@ iwconfig_force_preferred()
found_AP=true found_AP=true
break break
fi fi
i=$((${i} + 1)) : $(( i += 1 ))
done done
if ! ${found_AP}; then if ! ${found_AP}; then
SSID=${ssid} SSID=${ssid}
@ -559,7 +559,7 @@ iwconfig_connect_preferred()
iwconfig_associate "${mode}" "${mac}" "${enc}" "${freq}" \ iwconfig_associate "${mode}" "${mac}" "${enc}" "${freq}" \
"${chan}" && return 0 "${chan}" && return 0
fi fi
i=$((${i} + 1)) : $(( i += 1 ))
done done
done done
@ -593,7 +593,7 @@ iwconfig_connect_not_preferred()
"${chan}" && return 0 "${chan}" && return 0
fi fi
fi fi
i=$((${i} + 1)) : $(( i += 1 ))
done done
return 1 return 1

View File

@ -74,7 +74,7 @@ netplugd_pre_start()
fi fi
sleep 1 sleep 1
[ ${timeout} -eq 0 ] && continue [ ${timeout} -eq 0 ] && continue
i=$((${i} + 1)) : $(( i += 1 ))
[ ${i} -ge ${timeout} ] && break [ ${i} -ge ${timeout} ] && break
done done

View File

@ -96,7 +96,7 @@ pppd_pre_start()
if ! ${hasdefaultmetric}; then if ! ${hasdefaultmetric}; then
local m= local m=
eval m=\$metric_${IFVAR} eval m=\$metric_${IFVAR}
[ -z "${m}" ] && m=$((${metric} + $(_ifindex))) [ -z "${m}" ] && : $(( m = metric + $(_ifindex) ))
opts="${opts} defaultmetric ${m}" opts="${opts} defaultmetric ${m}"
fi fi
if [ -n "${mtu}" ]; then if [ -n "${mtu}" ]; then

View File

@ -30,7 +30,7 @@ tuntap_pre_start()
local timeout=10 local timeout=10
while [ ! -e /dev/net/tun -a ${timeout} -gt 0 ]; do while [ ! -e /dev/net/tun -a ${timeout} -gt 0 ]; do
sleep 1 sleep 1
timeout=$((${timeout} - 1)) : $(( timeout -= 1 ))
done done
if [ ! -e /dev/net/tun ]; then if [ ! -e /dev/net/tun ]; then
eerror "TUN/TAP support present but /dev/net/tun is not" eerror "TUN/TAP support present but /dev/net/tun is not"

View File

@ -34,7 +34,7 @@ _get_ssid()
return 0 return 0
fi fi
sleep 1 sleep 1
timeout=$((timeout - 1)) : $(( timeout -= 1 ))
done done
return 1 return 1

View File

@ -8,14 +8,14 @@ RC_GOT_FUNCTIONS="yes"
eindent() eindent()
{ {
EINFO_INDENT=$((${EINFO_INDENT:-0} + 2)) : $(( EINFO_INDENT = ${EINFO_INDENT:-0} + 2 ))
[ "$EINFO_INDENT" -gt 40 ] && EINFO_INDENT=40 [ "$EINFO_INDENT" -gt 40 ] && EINFO_INDENT=40
export EINFO_INDENT export EINFO_INDENT
} }
eoutdent() eoutdent()
{ {
EINFO_INDENT=$((${EINFO_INDENT:-0} - 2)) : $(( EINFO_INDENT = ${EINFO_INDENT:-0} - 2 ))
[ "$EINFO_INDENT" -lt 0 ] && EINFO_INDENT=0 [ "$EINFO_INDENT" -lt 0 ] && EINFO_INDENT=0
return 0 return 0
} }

View File

@ -59,7 +59,7 @@ do_unmount()
eend 1 eend 1
else else
local sig="TERM" local sig="TERM"
retry=$(($retry - 1)) : $(( retry -= 1 ))
[ $retry = 1 ] && sig="KILL" [ $retry = 1 ] && sig="KILL"
fuser $f_kill$sig -k $f_opts \ fuser $f_kill$sig -k $f_opts \
"$mnt" >/dev/null 2>&1 "$mnt" >/dev/null 2>&1

View File

@ -9,17 +9,17 @@ tret=0
ebegin "Testing yesno()" ebegin "Testing yesno()"
for f in yes YES Yes true TRUE True 1 ; do for f in yes YES Yes true TRUE True 1 ; do
if ! yesno $f; then if ! yesno $f; then
tret=$(($tret + 1)) : $(( tret += 1 ))
echo "!$f!" echo "!$f!"
fi fi
done done
for f in no NO No false FALSE False 0 ; do for f in no NO No false FALSE False 0 ; do
if yesno $f; then if yesno $f; then
tret=$(($tret + 1)) : $(( tret += 1 ))
echo "!$f!" echo "!$f!"
fi fi
done done
eend $tret eend $tret
ret=$(($ret + $tret)) : $(( ret += $tret ))
exit $ret exit $ret

View File

@ -15,7 +15,7 @@ checkit() {
echo "$@" | tr ' ' '\n' > ${base}.out echo "$@" | tr ' ' '\n' > ${base}.out
diff -u ${base}.list ${base}.out diff -u ${base}.list ${base}.out
eend $? eend $?
ret=$(($ret + $?)) : $(( ret += $? ))
} }
ret=0 ret=0
@ -65,7 +65,7 @@ readelf -Wr $(grep -l '#include[[:space:]]"librc\.h"' ${librc_srcdir}/*.c | sed
syms=$(diff -u librc.funcs.hidden.list librc.funcs.hidden.out | sed -n '/^+[^+]/s:^+::p') syms=$(diff -u librc.funcs.hidden.list librc.funcs.hidden.out | sed -n '/^+[^+]/s:^+::p')
[ -z "${syms}" ] [ -z "${syms}" ]
eend $? "Missing hidden defs:"$'\n'"${syms}" eend $? "Missing hidden defs:"$'\n'"${syms}"
ret=$(($ret + $?)) : $(( ret += $? ))
ebegin "Checking trailing whitespace in code" ebegin "Checking trailing whitespace in code"
# XXX: Should we check man pages too ? # XXX: Should we check man pages too ?
@ -118,7 +118,7 @@ for u in units/*; do
ebegin "$(basename "${u}")" ebegin "$(basename "${u}")"
./"${u}" ./"${u}"
eend $? eend $?
ret=$(($ret + $?)) : $(( ret += $? ))
done done
exit ${ret} exit ${ret}

View File

@ -34,7 +34,7 @@ while true; do
elif [ "${opt}" != "${opt#dhcp-option DNS *}" ]; then elif [ "${opt}" != "${opt#dhcp-option DNS *}" ]; then
NS="${NS}nameserver ${opt#dhcp-option DNS *}\n" NS="${NS}nameserver ${opt#dhcp-option DNS *}\n"
fi fi
i=$((${i} + 1)) : $(( i += 1 ))
done done
if [ -n "${NS}" ]; then if [ -n "${NS}" ]; then