Subject: Re: simple shell test question
To: Rob Windsor <windsor@warthog.com>
From: Christopher Vance <vance@aurema.com>
List: netbsd-users
Date: 06/06/2002 16:08:36
On Thu, Jun 06, 2002 at 12:54:43AM -0500, Rob Windsor wrote:
: On Thu, 06 Jun 2002 05:48:59 -0000, verily did Jim Breton write:
: 
: > In my travels I have often seen shell syntax like the following:
: 
: > [ x"$VAR" != x"value" ]
: 
: > What is the point of doing that instead of the following?
: 
: > [ "$VAR" != "value" ]
: 
: > Does the 'x' have some special meaning?  (If so, are there any other
: > characters with special meanings?)

Nothing special about 'x', and that's the point - it turns the first
word into an ordinary word, even when VAR starts with '-'.  Let's say
VAR is '-r'; in that case it thinks you're doing somethin like
	[ -r != "value" ]
which is syntactically incorrect.  It'll check for a file called '!='
and then barf on the extra argument.

-- 
Christopher Vance