<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Bash quoting</title>
	<atom:link href="http://blog.bigsmoke.us/2009/10/18/bash-quoting/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.bigsmoke.us/2009/10/18/bash-quoting</link>
	<description>Smokes your problems, coughs fresh air.</description>
	<lastBuildDate>Sat, 04 Feb 2012 20:03:14 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: halfgaar</title>
		<link>http://blog.bigsmoke.us/2009/10/18/bash-quoting#comment-104479</link>
		<dc:creator>halfgaar</dc:creator>
		<pubDate>Wed, 05 Jan 2011 08:23:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.bigsmoke.us/?p=850#comment-104479</guid>
		<description>Another test case:

often I do

&lt;code&gt;
EXCLUDE=&quot;--exclude /a --exclude /b&quot;
program $EXCLUDE -- source dest
&lt;/code&gt;

I was told again that eval is evil. But what if one of those to-be-excluded dirs contains a space? To test: when I do this:

&lt;code&gt;
touch a b c &#039;a b c&#039;
file=&quot;-l a b c &#039;a b c&#039;&quot;
ls $file
&lt;/code&gt;

I get:

&lt;blockquote&gt;
ls: cannot access &#039;a: No such file or directory
ls: cannot access c&#039;: No such file or directory
-rw-r--r-- 1 root root 0 2011-01-05 09:17 a
-rw-r--r-- 1 root root 0 2011-01-05 09:17 b
-rw-r--r-- 1 root root 0 2011-01-05 09:17 b
-rw-r--r-- 1 root root 0 2011-01-05 09:17 c
&lt;/blockquote&gt;

When I do: 

&lt;code&gt;
ls &quot;$file&quot;
&lt;/code&gt;

Then:

&lt;blockquote&gt;
ls: invalid option -- 
&lt;/blockquote&gt;

But when I do eval:

&lt;code&gt;
eval ls &quot;$file&quot;:
&lt;code&gt;

&lt;blockquote&gt;
-rw-r--r-- 1 root root 0 2011-01-05 09:17 a
-rw-r--r-- 1 root root 0 2011-01-05 09:17 a b c
-rw-r--r-- 1 root root 0 2011-01-05 09:17 b
-rw-r--r-- 1 root root 0 2011-01-05 09:17 c
&lt;/blockquote&gt;

I could define my excludes without the params and build it with a for loop, but in the end, I still have to include it in the command, so that doesn&#039;t make the problem go away. So, how do I do this?</description>
		<content:encoded><![CDATA[<p>Another test case:</p>
<p>often I do</p>
<p><pre class="php">EXCLUDE=<span style="color: #ff0000;">&quot;--exclude /a --exclude /b&quot;</span>
program <span style="color: #0000ff;">$EXCLUDE</span> -- source dest</pre></p>
<p>I was told again that eval is evil. But what if one of those to-be-excluded dirs contains a space? To test: when I do this:</p>
<p><pre class="php"><a href="http://www.php.net/touch"><span style="color: #000066;">touch</span></a> a b c <span style="color: #ff0000;">'a b c'</span>
<a href="http://www.php.net/file"><span style="color: #000066;">file</span></a>=<span style="color: #ff0000;">&quot;-l a b c 'a b c'&quot;</span>
ls <span style="color: #0000ff;">$file</span></pre></p>
<p>I get:</p>
<blockquote><p>
ls: cannot access &#8216;a: No such file or directory<br />
ls: cannot access c&#8217;: No such file or directory<br />
-rw-r&#8211;r&#8211; 1 root root 0 2011-01-05 09:17 a<br />
-rw-r&#8211;r&#8211; 1 root root 0 2011-01-05 09:17 b<br />
-rw-r&#8211;r&#8211; 1 root root 0 2011-01-05 09:17 b<br />
-rw-r&#8211;r&#8211; 1 root root 0 2011-01-05 09:17 c
</p></blockquote>
<p>When I do: </p>
<p><pre class="php">ls <span style="color: #ff0000;">&quot;$file&quot;</span></pre></p>
<p>Then:</p>
<blockquote><p>
ls: invalid option &#8212;
</p></blockquote>
<p>But when I do eval:</p>
<p><code><br />
eval ls "$file":<br />
</code><code></p>
<blockquote><p>
-rw-r--r-- 1 root root 0 2011-01-05 09:17 a<br />
-rw-r--r-- 1 root root 0 2011-01-05 09:17 a b c<br />
-rw-r--r-- 1 root root 0 2011-01-05 09:17 b<br />
-rw-r--r-- 1 root root 0 2011-01-05 09:17 c
</p></blockquote>
<p>I could define my excludes without the params and build it with a for loop, but in the end, I still have to include it in the command, so that doesn't make the problem go away. So, how do I do this?</code></p>
]]></content:encoded>
	</item>
</channel>
</rss>

