title: Bash scripting git branch lists
body: <p>This is probably a dumb mistake. I am using <a href="https://superuser.com/a/105389/143629">this as a basis for a bash function</a> to try to create a bash script for <a href="https://stackoverflow.com/questions/2514172/listing-each-branch-and-its-last-revisions-date-in-git/2514279#2514279">this git function</a>:</p>
  
  <pre><code>branch() {
     if [[ $@ == "-r" ]]; then
         command for k in `git branch -r | perl -pe 's/^..(.*?)( -&gt;.*)?$/\1/'`; do echo -e `git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k -- | head -n 1`\\t$k; done | sort -r
  
  else
        command for k in `git branch | perl -pe s/^..//`; do echo -e `git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k -- | head -n 1`\\t$k; done | sort -r
  
     fi
  }
  </code></pre>
  
  <p>When I try to source this, it actually is trying to execute the commands - and then gives a syntax error because of this.</p>
  
  <p>I am able to execute the commands locally, so clearly I am missing something obvious in creating my function here.</p>