<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 3 October 2014 22:45, Steve Coile <span dir="ltr"><<a href="mailto:scoile@mcclatchyinteractive.com" target="_blank">scoile@mcclatchyinteractive.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Suppose /usr/bin/zonename returned "-f", producing:<div><br></div><div>[ -f = global ]</div></div></blockquote><div><br></div><div>No, it would produce:</div><div><br></div><div>[ "-f" = "global" ]</div><div><br></div><div>which would fail to match of course, but would not produce a parsing mistake, which I assume is the reason for the "x" prefix.  The "-f" would not cause the shell to test for the existence of a file.</div><div><br></div><div>Actually, even an unquoted "-f" doesn't seem to fail to parse in this way.  A better test is to use "-eq", like this:</div><div><br></div><div><div>$ [ `echo 0 -eq` = "global" ] && echo true || echo false</div><div>-bash: [: =: integer expression expected</div><div>false</div><div><br></div><div>$ [ "`echo 0 -eq`" = "global" ] && echo true || echo false</div><div>false</div></div><div><br></div><div>The first example triggers the type of parsing problem that I think you are referring to, and trying to protect against.  The second one, with the double quotes around the expression, eliminates the problem.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>Richard's approach is a good one in the general case, even if in this case it's very unlikely to have any practical effect.  I use Richard's approach myself.  You should, too.  :)<br></div></div></blockquote></div><br>Richard's way works, so that's fine.  As a matter of style, I don't like it because it's not clear what it's trying to do, and distracts from the readability of the code.  The fact that Richard felt he needed to explain the reason for the "x" reinforces my view on this.  I won't be using the this technique; and instead, for improved readability I'll continue to recommend that people rely on double quotes.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Cheers<br></div><div class="gmail_extra">Jeremy</div><div class="gmail_extra"><br></div></div>