Xref: utzoo comp.unix.questions:6935 comp.unix.wizards:8352
Path: utzoo!mnetor!uunet!steinmetz!davidsen
From: davidsen@steinmetz.ge.com (William E. Davidsen Jr)
Newsgroups: comp.unix.questions,comp.unix.wizards
Subject: funny in 'test'
Message-ID: <10778@steinmetz.ge.com>
Date: 10 May 88 18:47:46 GMT
Organization: GE Corp. R & D, Schenectady,NY
Lines: 18
Keywords: test


  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 =" should test for a directory named "=", followed by a barf on the
operator "x". This script in fact compared strings on a number of
systems, and blew up on only a few. I believe that it should fail, but
would like some opinions on this.

  I fixed it by inverting the test, but it really looks as though some
shells assume a precedence of operators in the shell. A good reason
never to put ANY shell variable in the first position of an = test.
-- 
	bill davidsen		(wedu@ge-crd.arpa)
  {uunet | philabs | seismo}!steinmetz!crdos1!davidsen
"Stupidity, like virtue, is its own reward" -me