Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 5/3/83; site ukc.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!mcvax!ukc!lmcl From: lmcl@ukc.UUCP (L.M.McLoughlin) Newsgroups: net.unix Subject: Re: Why do people use: if [ "x$FOO" = "x" ] .... ? Message-ID: <5046@ukc.UUCP> Date: Fri, 19-Apr-85 15:48:59 EST Article-I.D.: ukc.5046 Posted: Fri Apr 19 15:48:59 1985 Date-Received: Mon, 15-Apr-85 03:47:44 EST References: <361@ho95b.UUCP> Reply-To: lmcl@ukc.UUCP (L.McLoughlin) Organization: Computing Laboratory, U of Kent at Canterbury, UK Lines: 23 In article <361@ho95b.UUCP> wcs@ho95b.UUCP writes: > > I've seen a lot of Bourne shell scripts that test for >blank variables using the construct > if [ "x$FOO" = "x" ] > ... > if [ "$FOO" = "" ] >or > if [ -z "$FOO" ] How about: case "$FOO" in '') echo ALL GONE;; *) echo Something here;; esac Unless you have '[' built into your shell this is generally a lot faster but maybe less readable. I too used to use the "x$VAR" type tests and kicked myself when I saw the case equivalent in the rn sources.