Why do people use: if [ "x$FOO" = "x" ] .... ?
Henry Spencer
henry at utzoo.UUCP
Sun Apr 21 10:34:33 AEST 1985
> Suppose you are asking for confirmation and you want any of "y", "ye",
> or "yes", or "yo" or anything else starting with "y" to mean "yes",
> and anything starting with "n" to mean "no". ...
>
> Using "$answer" doesn't work unless you explicitly list ALL of the choices,
> since "*" isn't expanded inside strings...
Huh? The following has always worked perfectly for us, on both V7
and SysV shells:
case "$answer"
in
y*)
echo yes
;;
n*)
echo no
;;
*)
echo huh
;;
esac
Just to be doubly sure, I just wrote out the above example and tried
it. Works fine.
--
Henry Spencer @ U of Toronto Zoology
{allegra,ihnp4,linus,decvax}!utzoo!henry
More information about the Comp.unix
mailing list