[Xymon] Configuring Devmon for the first time

Buchan Milne bgmilne at staff.telkomsa.net
Thu Jun 2 10:10:27 CEST 2011


On Thursday, 2 June 2011 09:37:01 John P Martin wrote:
> I agree it's a bit off-topic, but just to answer the question:
> 
> The "x" prefix for testing variables (more commonly the upper case "X",
> because that's the example in the man page :-)

Out of curiosity, which man page?

> is common practice to avoid
> the test getting confused by unexpected values in the variable,

in crappy shells (typically found on crufty old proprietary Unix).

> In
> particular, the test tends to throw the comparison out if the variable
> should start with a "-".  Prefixing the variable would convert this to
> "X-", which is correctly processed by the test comparison.
> 
> For example:
> 
> VAR="-value"
> 
> [ "$VAR" == "something" ] will fail, trying to process "-value" as a
> qualifier.
> 
> [ "X$VAR" == "Xsomething" ] will correctly find an inequality

$ foo=purple;if [ "$foo" == "purple" ];then echo yes;else echo no;fi
yes
$ foo="-blue";if [ "$foo" == "purple" ];then echo yes;else echo no;fi
no
$ foo="red";if [ "$foo" == "purple" ];then echo yes;else echo no;fi
no
$ echo $SHELL
/bin/bash

Regards,
Buchan



More information about the Xymon mailing list