title: Bash : weird behavior with variable contain
body: <p>I am using a simple bash function which executes a dbus command and retrieve its result.    </p>
  
  <pre><code>getValue()
  {
   local -i val   
   declare -a array
  
   array=($(dbus-send --system --print-reply ...))
   val=${array[7]}
   echo $val
   unset array
  
   if [ ! -z ${val} ]
   then   
    ...
   fi
  }
  </code></pre>
  
  <p>While the dbus command return an expected value the function works fine. However, when the dbus is in a bad state : </p>
  
  <pre><code>Error org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: ...
  </code></pre>
  
  <p>the "echo $val" returns 0 and the condition if [ ! -z "$val" ] is satisfied. How to avoid this incorrect state ?  </p>