httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Jagielski <>
Subject Re: cvs commit: apache-1.3/src Configure
Date Sat, 16 Jan 1999 16:52:38 GMT
Tony Finch wrote:
> Jim Jagielski <> wrote:
> >
> >Nope. The manual says that AS LONG as both sides are wrapped by double
> >quotes, then there is NO problem. The problem exists for things like:
> >
> >	if [ $VALUE = test ]
> >
> >if $VALUE is null, then the shell will barf. There are 2 methods to avoid
> >this:
> >
> >	if [ x$VALUE = xtest ]
> >
> > or
> >
> >	if [ "$VALUE" = "test" ]
> What if either $VALUE or test are operators? Won't that cause a syntax
> error?

If wrapped in "", the System 7 manual states that things are protected.
Back then, [] was implemented as 'test' so if they were not wrapped,
test would see, for example,

   if test $VALUE = text

if $VALUE was null, what would be see would be

   if test  = text

And the 'test' command would barf. Even if "$VALUE" or "text" where
"option-like" strings (beginning with '-') then as long as they were
wrapped, things should be OK. For example, the below is supposed to

   if [ "-a" = "-z" -a "-k" != "-lalala" ]

however, some broken shells/tests did not/do not follow this. It's for
this reason that the universal hack of "x$VAL" != "x-whatever" has
been used. ksh, bash and up-to-date Bournes operate correctly whether
wrapped or not. In fact, ksh and bash are guaranteed to behave properly
and not require any ugly hacks.

Even so, I've always been ultra conservative and would use both the "" wrap
AND the 'x' hack. In a momentary lack of judgement, in an effort to
avoid offending anyone, I went against my judgement and "decided" that
simple wrapping was sufficient and adjusted the scripts.

That teaches me a lesson. Never go against your judgement for fear of stepping
on someone's toes. It'll bite you in the ass in the end :)

   Jim Jagielski   |||   |||
            "That's no ordinary rabbit... that's the most foul,
            cruel and bad-tempered rodent you ever laid eyes on"

View raw message