title: Capturing and testing output command in ZSH
body: <p>I have tried countless ways to get what I want, but nothing seems to work. I always end up with something like <code>2:not found</code>.</p>
  
  <p>I want to capture the output of a command, and then test if it equals "!", like so:</p>
  
  <pre><code>function test() {
    local testv=$(command) 2&gt;/dev/null
    if [ $(#testv) == "!" ]; then
      echo "Exclamation mark!"
    else
      echo "No exclamation mark."
    fi
  }
  </code></pre>
  
  <p>How should I rewrite the code above to avoid the error <code>test:2: = not found</code>?</p>