Blob Blame History Raw
From 6f006ae0c1efbbb90d00cbb340001e74d8d12db1 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Fri, 22 Jun 2012 15:34:24 +0200
Subject: [PATCH] dracut-logger.sh: use (( )) for numeric comparisons

---
 dracut-logger.sh |   20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/dracut-logger.sh b/dracut-logger.sh
index f1b3a7e..a78e18e 100755
--- a/dracut-logger.sh
+++ b/dracut-logger.sh
@@ -116,7 +116,7 @@ dlog_init() {
 
     if [ -z "$fileloglvl" ]; then
         [ -w "$logfile" ] && fileloglvl=4 || fileloglvl=0
-    elif [ $fileloglvl -gt 0 ]; then
+    elif (( $fileloglvl >= 0 )); then
         __oldumask=$(umask)
         umask 0377
         ! [ -e "$logfile" ] && >"$logfile"
@@ -138,7 +138,7 @@ dlog_init() {
         fi
     fi
 
-    if [ $sysloglvl -gt 0 ]; then
+    if (( $sysloglvl >= 0 )); then
         if ! [ -S /dev/log -a -w /dev/log ] || ! command -v logger >/dev/null
         then
             # We cannot log to syslog, so turn this facility off.
@@ -148,7 +148,7 @@ dlog_init() {
         fi
     fi
 
-    if [ $sysloglvl -gt 0 -o $kmsgloglvl -gt 0 ]; then
+    if (($sysloglvl >= 0)) || (($kmsgloglvl >= 0 )); then
         if [ -n "$dracutbasedir" ]; then
             readonly syslogfacility=user
         else
@@ -159,7 +159,7 @@ dlog_init() {
 
     local lvl; local maxloglvl_l=0
     for lvl in $stdloglvl $sysloglvl $fileloglvl $kmsgloglvl; do
-        [ $lvl -gt $maxloglvl_l ] && maxloglvl_l=$lvl
+        (( $lvl > $maxloglvl_l )) && maxloglvl_l=$lvl
     done
     readonly maxloglvl=$maxloglvl_l
     export maxloglvl
@@ -275,14 +275,14 @@ _do_dlog() {
     local lvlc=$(_lvl2char "$lvl") || return 0
     local msg="$lvlc: $*"
 
-    [ $lvl -le $stdloglvl ] && echo "$msg" >&2
-    if [ $lvl -le $sysloglvl ]; then
+    (( $lvl <= $stdloglvl )) && echo "$msg" >&2
+    if (( $lvl <= $sysloglvl )); then
         logger -t "dracut[$$]" -p $(_lvl2syspri $lvl) "$msg"
     fi
-    if [ $lvl -le $fileloglvl -a -w "$logfile" -a -f "$logfile" ]; then
+    if (( $lvl <= $fileloglvl )) && [[ -w "$logfile" ]] && [[ -f "$logfile" ]]; then
         echo "$msg" >>"$logfile"
     fi
-    [ $lvl -le $kmsgloglvl ] && \
+    (( $lvl <= $kmsgloglvl )) && \
         echo "<$(_dlvl2syslvl $lvl)>dracut[$$] $msg" >/dev/kmsg
 }
 
@@ -304,9 +304,9 @@ _do_dlog() {
 # echo "This is a warning" | dwarn
 dlog() {
     [ -z "$maxloglvl" ] && return 0
-    [ $1 -le $maxloglvl ] || return 0
+    (( $1 <= $maxloglvl )) || return 0
 
-    if [ $# -gt 1 ]; then
+    if (( $# > 1 )); then
         _do_dlog "$@"
     else
         while read line; do