title: zsh variable assignment within if
body: <p>This is my first question here so ... i hope i do it right.</p>
  
  <p>I'm trying to write a little zsh script - following example simplifies what I have:</p>
  
  <pre><code>function example {
      if [ $1 == "my_string" ]; then
          local my_variable=10
      fi
      echo $my_variable
  }
  
  // i want
  $&gt; example my_string
  $&gt; 10
  
  // i get
  $&gt; example:1: = not found
  </code></pre>
  
  <p>I've been trying with and without local variables, i tried declare and with or without spaces aswell as googling for hours.</p>
  
  <p>t.i.a.</p>
  
  <p>EDIT: ADDITIONAL INFORMATION
  I'm using Mac OSX Mavericks - iTerm2 and I installed oh-my-zsh - this script is written directly within my ~/.zshrc</p>