title: rsync ignores --exclude options being run in bash script
body: <p>I've spent dozen man hours were trying to understand why rsync ignores options --exclude being running in script in spite of the same command were perfectly working from command line.</p>
  <p>Bash-script (a part of):
  <code>EXCEPTIONS=&quot;$EXCEPTIONS --exclude=$ex&quot;</code> - fills-in variable with list of excludes, reading from file in loop.
  And this is how rsync is run:
  <code>rsync -aus --no-verbose $EXCEPTIONS &quot;$SOURCEDIR/$backup_path/&quot; &quot;$SYNCTODIR/$backup_path&quot;</code></p>
  <p>It works. Finally.</p>
  <p>BUT. If you try to use quotes in excludes, like this: <code>EXCEPTIONS=&quot;$EXCEPTIONS --exclude='$ex'&quot;</code> or like this: <code>EXCEPTIONS=&quot;$EXCEPTIONS --exclude=\&quot;$ex\&quot;&quot;</code> you'll get the situation when rsync is run with --exclude parameters but it don't care on what you wrote as a value in them - it will merely ignore excludes. At the same time, there is no difference between using or not quotes in SOURCE and DESTINATION.</p>
  <p>And yes, it works if you run rsync from shell (not in script) and use or not quotes in --exclude. I think the same situation is with other parameters.</p>
  <p>I'd be very appreciated if someone could explain such behavior. Thank you.</p>
  <p>UPDATE1:
  Thank you, Jetchisel, I've read about word splitting but let's takle a look at how it works. Two scripts:</p>
  <pre><code>#!/bin/bash
  echo $IFS
  printf &quot;%d args:&quot; &quot;$#&quot;
  printf &quot; &lt;%s&gt;&quot; &quot;$@&quot;
  echo
  </code></pre>
  <p>and</p>
  <pre><code>#!/bin/bash
  ./test.sh  -arqu --exclude 'dshul' --exclude 'RegressionTest' --exclude 'builds' odashare2/QA/ share/QA
  ./test.sh  -arqu --exclude='dshul' --exclude='RegressionTest' --exclude='builds' &quot;odashare2/QA/&quot; &quot;share/QA&quot;
  </code></pre>
  <p>The second just run first one with parameters. And now outcome of running of these scripts:</p>
  <pre><code>
  6 args: &lt;-arqu&gt; &lt;--exclude=dshul&gt; &lt;--exclude=RegressionTest&gt; &lt;--exclude=builds&gt; &lt;odashare2/QA/&gt; &lt;share/QA&gt;
  admin@odastorage2:~$ ./test.sh  -arqu --exclude='dshul' --exclude='RegressionTest' --exclude='builds' &quot;odashare2/QA/&quot; &quot;share/QA&quot;
  
  6 args: &lt;-arqu&gt; &lt;--exclude=dshul&gt; &lt;--exclude=RegressionTest&gt; &lt;--exclude=builds&gt; &lt;odashare2/QA/&gt; &lt;share/QA&gt;
  admin@odastorage2:~$ ./test.sh  -arqu --exclude 'dshul' --exclude 'RegressionTest' --exclude 'builds' odashare2/QA/ share/QA
  
  9 args: &lt;-arqu&gt; &lt;--exclude&gt; &lt;dshul&gt; &lt;--exclude&gt; &lt;RegressionTest&gt; &lt;--exclude&gt; &lt;builds&gt; &lt;odashare2/QA/&gt; &lt;share/QA&gt;
  admin@odastorage2:~$
  admin@odastorage2:~$
  admin@odastorage2:~$ ./testar.sh
  
  9 args: &lt;-arqu&gt; &lt;--exclude&gt; &lt;dshul&gt; &lt;--exclude&gt; &lt;RegressionTest&gt; &lt;--exclude&gt; &lt;builds&gt; &lt;odashare2/QA/&gt; &lt;share/QA&gt;
  
  6 args: &lt;-arqu&gt; &lt;--exclude=dshul&gt; &lt;--exclude=RegressionTest&gt; &lt;--exclude=builds&gt; &lt;odashare2/QA/&gt; &lt;share/QA&gt;
  </code></pre>
  <p>Looks reasonable and clear. So I still don't understand what's wrong with rsync.</p>