Xref: utzoo comp.unix.questions:6980 comp.unix.wizards:8412 Path: utzoo!utgpu!water!watmath!clyde!bellcore!decvax!gsg!lew From: lew@gsg.UUCP (Paul Lew) Newsgroups: comp.unix.questions,comp.unix.wizards Subject: Re: funny in 'test' Message-ID: <151@gsg.UUCP> Date: 12 May 88 14:33:33 GMT References: <10778@steinmetz.ge.com> Organization: General Systems Group, Inc., Salem, NH Lines: 20 > 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