title: Bash: How to do a variable expansion within an arithmetic expression?
body: <p>While attempting to write a simple bash script to help 
  with my deployment process, I ran in to a confusing error:</p>
  
  <pre><code>#!/bin/bash
  WEEKDAY=$(date +'%u')
  echo $WEEKDAY
  DAYS_TO_WEDNESDAY=$((3-$WEEKDAY))
  echo $DAYS_TO_WEDNESDAY
  </code></pre>
  
  <p>Results in:</p>
  
  <pre><code>1
  ")syntax error: invalid arithmetic operator (error token is "
  </code></pre>
  
  <p>The strangest part of it is that I could swear that this
  very script ran perfectly well some days ago.</p>
  
  <h2>EDIT (14:58):</h2>
  
  <p>The issue was not with the bash script, but with using SVN through TortoiseSVN. The detour through Windows changed EOL markers to "CR LF", which result in syntax errors in bash.  Setting svn:eol-style -property helps avoid further similar issues.</p>