Suppose /usr/bin/zonename returned "-f", producing:
[ -f = global ]
which would fail because "=" likely isn't a filename, a test for the existence of a file by that name likely isn't anywhere close to what you want to do, and "global" would be an unrecognized argument.
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. :)
--
*Steve Coile*Senior Network and Systems Engineer, McClatchy Interactive <http://www.mcclatchyinteractive.com/> Office: 919-861-1247 | Mobile: 919-622-5369 | Fax: 919-861-1300
On Fri, Oct 3, 2014 at 2:31 AM, Jeremy Laidman <jlaidman at rebel-it.com.au> wrote:
On 2 October 2014 02:46, Richard L. Hamilton <rlhamil2 at gmail.com> wrote:
if [ -x /usr/bin/zonename ] && [ x”
/usr/bin/zonename” = x”global” ](the x in front of the strings being compared is just paranoia against one of them having a syntactically confusing value, like a dash option or an = sign)
I could be wrong, but I don't know of any shell that would misinterpret a dash or equals when inside double quotes.
J
Xymon mailing list Xymon at xymon.com http://lists.xymon.com/mailman/listinfo/xymon