From ef1ff1b4f29762d1caf83dc2b65ccfc7cb96e140 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 10 Nov 2011 21:46:08 -0500 Subject: 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 --- init.d/net.lo.in | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'init.d/net.lo.in') diff --git a/init.d/net.lo.in b/init.d/net.lo.in index 66e1945..d647f31 100644 --- a/init.d/net.lo.in +++ b/init.d/net.lo.in @@ -115,7 +115,7 @@ _wait_for_carrier() eend 0 return 0 fi - timeout=$((${timeout} - 1)) + : $(( timeout -= 1 )) [ "${efunc}" = "einfon" ] && printf "." done @@ -144,9 +144,9 @@ _netmask2cidr() local i= len= local IFS=. for i in $1; do - while [ ${i} != "0" ]; do - len=$((${len} + ${i} % 2)) - i=$((${i} >> 1)) + while [ i -ne 0 ]; do + : $(( len += i % 2 )) + : $(( i >>= 1 )) done done @@ -277,7 +277,7 @@ _gen_module_list() echo "module_${i}_program_start='${PROGRAM_START}'" >> "${MODULESLIST}" echo "module_${i}_program_stop='${PROGRAM_STOP}'" >> "${MODULESLIST}" echo "module_${i}_provide='${PROVIDE}'" >> "${MODULESLIST}" - i=$((${i} + 1)) + : $(( i += 1 )) done echo "module_${i}=" >> "${MODULESLIST}" ) @@ -304,7 +304,7 @@ _load_modules() local i=-1 x= mod= f= provides= while true; do - i=$((${i} + 1)) + : $(( i += 1 )) eval mod=\$module_${i} [ -z "${mod}" ] && break [ -e "${MODULESDIR}/${mod}.sh" ] || continue @@ -438,7 +438,7 @@ _load_config() # so modules can influence it for cmd; do eval config_${config_index}="'${cmd}'" - config_index=$((${config_index} + 1)) + : $(( config_index += 1 )) done # Terminate the list eval config_${config_index}= @@ -446,7 +446,7 @@ _load_config() config_index=0 for cmd in ${fallback}; do eval fallback_${config_index}="'${cmd}'" - config_index=$((${config_index} + 1)) + : $(( config_index += 1 )) done # Terminate the list eval fallback_${config_index}= @@ -541,7 +541,7 @@ start() if [ -n "${our_metric}" ]; then metric=${our_metric} elif [ "${IFACE}" != "lo" -a "${IFACE}" != "lo0" ]; then - metric=$((${metric} + $(_ifindex))) + : $(( metric += $(_ifindex) )) fi while true; do @@ -581,11 +581,11 @@ start() eindent eval config_${config_index}=\$config unset fallback_${config_index} - config_index=$((${config_index} - 1)) + : $(( config_index -= 1 )) fi fi eoutdent - config_index=$((${config_index} + 1)) + : $(( config_index += 1 )) done if ! ${oneworked}; then -- cgit v1.2.3