Xref: utzoo comp.unix.questions:6946 comp.unix.wizards:8365 Path: utzoo!utgpu!water!watmath!clyde!ima!think!barmar From: barmar@think.COM (Barry Margolin) Newsgroups: comp.unix.questions,comp.unix.wizards Subject: Re: funny in 'test' Keywords: test Message-ID: <20666@think.UUCP> Date: 11 May 88 05:02:54 GMT References: <10778@steinmetz.ge.com> Sender: usenet@think.UUCP Reply-To: barmar@kulla.think.com.UUCP (Barry Margolin) Organization: Thinking Machines Corporation, Cambridge, MA Lines: 19 In article <10778@steinmetz.ge.com> davidsen@steinmetz.ge.com (William E. Davidsen Jr) writes: > if [ "$1" = "x" ]; then do something; fi >A good reason >never to put ANY shell variable in the first position of an = test. Another common convention is to put an extra character onto the front of both parts of the test, e.g. if [ "x$1" = "xx" ]; ... That way, if $1 starts with a hyphen, this becomes something like if [ "x-d" = "xx" ] Barry Margolin Thinking Machines Corp. barmar@think.com uunet!think!barmar