From eabadd8e6a20252b8ff2f7fde35fd0976a421be8 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 20 Mar 2019 21:04:34 +0800 Subject: [PATCH] sg3_utils: fix syntax error reason: when some variable not set, test its value, it will show "test: =: unary operator expected" error message --- scripts/rescan-scsi-bus.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/rescan-scsi-bus.sh b/scripts/rescan-scsi-bus.sh index 4fa5e6c..9bfd3be 100755 --- a/scripts/rescan-scsi-bus.sh +++ b/scripts/rescan-scsi-bus.sh @@ -85,10 +85,10 @@ findhosts () hosts= for driverdir in /proc/scsi/*; do driver=${driverdir#/proc/scsi/} - if test $driver = scsi -o $driver = sg -o $driver = dummy -o $driver = device_info; then continue; fi + if test x$driver = xscsi -o x$driver = xsg -o x$driver = xdummy -o x$driver = xdevice_info; then continue; fi for hostdir in $driverdir/*; do name=${hostdir#/proc/scsi/*/} - if test $name = add_map -o $name = map -o $name = mod_parm; then continue; fi + if test x$name = xadd_map -o x$name = xmap -o x$name = xmod_parm; then continue; fi num=$name driverinfo=$driver if test -r $hostdir/status; then @@ -254,7 +254,7 @@ testonline () print_and_scroll_back "$host:$channel:$id:$lun $SGDEV ($RMB) " test $RC = 2 -a "$RMB" = "1" && break done - if test $ctr != 0; then white_out; fi + if test x$ctr != x0; then white_out; fi # echo -e "\e[A\e[A\e[A${yellow}Test existence of $SGDEV = $RC ${norm} \n\n\n" if test $RC = 1; then return $RC; fi # Reset RC (might be !=0 for passive paths) @@ -512,7 +512,7 @@ dolunscan() # Device not present printf "\r\e[A"; # Optimization: if lun==0, stop here (only if in non-remove mode) - if test $lun = 0 -a -z "$remove" -a $optscan = 1; then + if test x$lun = x0 -a -z "$remove" -a x$optscan = x1; then break; fi else @@ -1193,7 +1193,7 @@ if [ -d /sys/class/scsi_host -a ! -w /sys/class/scsi_host ]; then fi if test "$sync" = 1 -a "$remove" = 1; then sync=2; fi if test "$sync" = 2; then echo "Syncing file systems"; sync; fi -if test -w /sys/module/scsi_mod/parameters/default_dev_flags -a $scan_flags != 0; then +if test -w /sys/module/scsi_mod/parameters/default_dev_flags -a x$scan_flags != x0; then OLD_SCANFLAGS=`cat /sys/module/scsi_mod/parameters/default_dev_flags` NEW_SCANFLAGS=$(($OLD_SCANFLAGS|$scan_flags)) if test "$OLD_SCANFLAGS" != "$NEW_SCANFLAGS"; then -- 2.19.1