From fb595f55d1a6d0b333f3ad59e290b7657f28e569 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Lyson=C4=9Bk?= Date: Tue, 8 May 2018 20:54:58 +0200 Subject: [PATCH] fancontrol: Do command substitution in double quotes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Do command substitution in double quotes to prevent word splitting. The issue was reported by Coverity Scan. Signed-off-by: Ondřej Lysoněk --- prog/pwm/fancontrol | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/prog/pwm/fancontrol b/prog/pwm/fancontrol index eafb7d2b..000a09be 100755 --- a/prog/pwm/fancontrol +++ b/prog/pwm/fancontrol @@ -421,12 +421,12 @@ function pwmdisable() # check if setting pwmN_enable value was successful. Checking the # pwmN value makes no sense, as it might already have been altered # by the chip. - if [ $(cat $ENABLE) = ${PWM_ENABLE_ORIG_STATE[${1}]} ] + if [ "$(cat $ENABLE)" = ${PWM_ENABLE_ORIG_STATE[${1}]} ] then return 0 fi # if pwmN_enable is manual (1), check if restoring the pwmN value worked - elif [ $(cat ${1}) = ${PWM_ORIG_STATE[${1}]} ] + elif [ "$(cat ${1})" = ${PWM_ORIG_STATE[${1}]} ] then return 0 fi @@ -434,7 +434,7 @@ function pwmdisable() # Try pwmN_enable=0 echo 0 > $ENABLE 2> /dev/null - if [ $(cat $ENABLE) -eq 0 ] + if [ "$(cat $ENABLE)" -eq 0 ] then # Success return 0 @@ -443,14 +443,14 @@ function pwmdisable() # It didn't work, try pwmN_enable=1 pwmN=255 echo 1 > $ENABLE 2> /dev/null echo $MAX > $1 - if [ $(cat $ENABLE) -eq 1 -a $(cat $1) -ge 190 ] + if [ "$(cat $ENABLE)" -eq 1 -a "$(cat $1)" -ge 190 ] then # Success return 0 fi # Nothing worked - echo "$ENABLE stuck to" $(cat $ENABLE) >&2 + echo "$ENABLE stuck to" "$(cat $ENABLE)" >&2 return 1 }