funny in 'test'
Paul Lew
lew at gsg.UUCP
Fri May 13 00:33:33 AEST 1988
> I had a user find a good (?) one the other day. She has a shell script
> which did something like:
> if [ "$1" = "x" ]; then do something; fi
>
> The value passed in as the first argument was "-d". Now, the construct
> "-d =" ...
on BSD 4.* system, you will find out '[' is actually a link to
'/bin/test' and it is NOT part of the shell. Test expect a lot of
flags; -r, -w, -f, -d, -s, -t -z -n, etc (see man page for test). If
you need string comparison, always prefix by other characters like:
if [ "_$1" = "_$x" ]; then ...
(system V sh has test built-in, probably interprete '[' to be 'test' like
BSD?)
--
Paul Lew {oliveb,harvard,decvax}!gsg!lew (UUCP)
General Systems Group, 5 Manor Parkway, Salem, NH 03079 (603) 893-1000
More information about the Comp.unix.wizards
mailing list