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 --- sh/functions.sh.in | 4 ++-- sh/rc-mount.sh | 2 +- sh/runtests.sh | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'sh') diff --git a/sh/functions.sh.in b/sh/functions.sh.in index 1d1b0cd0..b00ec68e 100644 --- a/sh/functions.sh.in +++ b/sh/functions.sh.in @@ -8,14 +8,14 @@ RC_GOT_FUNCTIONS="yes" eindent() { - EINFO_INDENT=$((${EINFO_INDENT:-0} + 2)) + : $(( EINFO_INDENT = ${EINFO_INDENT:-0} + 2 )) [ "$EINFO_INDENT" -gt 40 ] && EINFO_INDENT=40 export EINFO_INDENT } eoutdent() { - EINFO_INDENT=$((${EINFO_INDENT:-0} - 2)) + : $(( EINFO_INDENT = ${EINFO_INDENT:-0} - 2 )) [ "$EINFO_INDENT" -lt 0 ] && EINFO_INDENT=0 return 0 } diff --git a/sh/rc-mount.sh b/sh/rc-mount.sh index b3c9bf63..2bb14504 100644 --- a/sh/rc-mount.sh +++ b/sh/rc-mount.sh @@ -59,7 +59,7 @@ do_unmount() eend 1 else local sig="TERM" - retry=$(($retry - 1)) + : $(( retry -= 1 )) [ $retry = 1 ] && sig="KILL" fuser $f_kill$sig -k $f_opts \ "$mnt" >/dev/null 2>&1 diff --git a/sh/runtests.sh b/sh/runtests.sh index 7f7e7bdd..f083ff46 100755 --- a/sh/runtests.sh +++ b/sh/runtests.sh @@ -9,17 +9,17 @@ tret=0 ebegin "Testing yesno()" for f in yes YES Yes true TRUE True 1 ; do if ! yesno $f; then - tret=$(($tret + 1)) + : $(( tret += 1 )) echo "!$f!" fi done for f in no NO No false FALSE False 0 ; do if yesno $f; then - tret=$(($tret + 1)) + : $(( tret += 1 )) echo "!$f!" fi done eend $tret -ret=$(($ret + $tret)) +: $(( ret += $tret )) exit $ret -- cgit v1.2.3