<br><br><div class="gmail_quote">On Fri, Oct 8, 2010 at 10:09 PM, Eliot Miranda <span dir="ltr">&lt;<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br><br><div class="gmail_quote"><div><div></div><div class="h5">On Fri, Oct 8, 2010 at 9:02 PM, K. K. Subramaniam <span dir="ltr">&lt;<a href="http://kksubbu.ml" target="_blank">kksubbu.ml</a>@<a href="http://gmail.com" target="_blank">gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>On Saturday 09 Oct 2010 4:06:37 am Eliot Miranda wrote:<br>
&gt;     Bert is very probably right.  If you&#39;re suing bourne/bash then look up<br>
&gt; the difference between $*, &quot;$*&quot;, $@ and &quot;$@&quot;.  To preserve spaces you need<br>
&gt; to use $@/&quot;$@&quot; (depending on context&quot; not $*.  Also within your script you<br>
&gt; can use IFS to prevent space being a separator.<br>
</div>‌$@ always uses space as word separator while $* uses the first letter of IFS<br>
variable. Otherwise they are the same.‌ Smalltalk uses spaces for separator so<br>
$@ will do.<br></blockquote><div><br></div><div><br></div></div></div><div>No.  $@ expands to the argument list as supplied to the current command:</div></div></blockquote><div><br></div><div><br></div><div>I should have written</div>
<div>     &quot;$@&quot; expands to the argument list as supplied to the current command:</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="gmail_quote">
<div><br></div><div><div>       *      Expands  to  the positional parameters, starting from one.  When</div>
<div>              the expansion occurs within double quotes, it expands to a  sin-</div><div>              gle word with the value of each parameter separated by the first</div><div>              character of the IFS special variable.  That is, &quot;$*&quot; is equiva-</div>

<div>              lent to &quot;$1c$2c...&quot;, where c is the first character of the value</div><div>              of the IFS variable.  If IFS is unset, the parameters are  sepa-</div><div>              rated  by  spaces.   If  IFS  is null, the parameters are joined</div>

<div>              without intervening separators.</div><div>       @      Expands to the positional parameters, starting from  one.   When</div><div>              the  expansion  occurs  within  double  quotes,  each  parameter</div>

<div>              expands to a separate word.  That is, &quot;$@&quot; is equivalent to &quot;$1&quot;</div><div>              &quot;$2&quot;  ... </div></div><div><br></div><div>So when invoking a command from within a shell wrapper one should use &quot;$@&quot; to pass on the parameters as this preserves whitespace within parameters.</div>

<div>e.g.</div><div>-----------8&lt;----------- printargs -----------8&lt;-----------</div><div><div>#!/bin/sh</div><div>while [ $# -gt 0 ]; do</div><div>    echo &quot;    &quot;&quot;$1&quot;</div><div>    shift</div><div>

done</div></div><div>-----------8&lt;----------- wrapper -----------8&lt;-----------</div><div><div>#!/bin/sh</div><div>echo &#39;$*&#39;</div><div>printargs $*  </div><div>echo &#39;&quot;$*&quot;&#39;</div><div>printargs &quot;$*&quot;</div>

<div>echo &#39;$@&#39;</div><div>printargs $@</div><div>echo &#39;&quot;$@&quot;&#39;</div><div>printargs &quot;$@&quot;</div></div><div>-----------8&lt;-----------</div><div>$ wrapper &quot;hello world&quot; hello world</div>

<div>prints:</div><div><div>$*</div><div>    hello</div><div>    world</div><div>    hello</div><div>    world</div><div>&quot;$*&quot;</div><div>    hello world hello world</div><div>$@</div><div>    hello</div><div>    world</div>

<div>    hello</div><div>    world</div><div>&quot;$@&quot;</div><div>    hello world</div><div>    hello</div><div>    world</div></div><div><br></div><div><br></div><div>HTH </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<br>
Subbu<br>
</blockquote></div><br>
</blockquote></div><br>