HELP! (What's wrong with this sh scr - (nf)

ShanklandJA jas at drutx.UUCP
Wed Apr 25 05:54:31 AEST 1984


    > To guard against this, always (1) use double-quotes around
    > your read-in strings and (2) pad such strings with a leading
    > character to keep them from ever being null:

        > if [ "X$ANSWER" = Xyes -o "X$ANSWER" = Xye -o "X$ANSWER" = Xy ]

I've always wondered about this curious custom of prefixing strings with X
(or whatever) to keep them from being null.  Why?  The System V Bourne
shell finds null strings perfectly acceptable; of course, they have to be
quoted, because the empty string is not the same as no string at all.  In
any case, I find that:

if [ "$ANSWER" = yes -o "$ANSWER" = ye -o "$ANSWER" = y ]

works just fine, even when $ANSWER is null.  Those X's look ugly to me.
Am I missing something?

Jim Shankland
..!ihnp4!druxy!jas



More information about the Comp.unix mailing list