Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site ho95b.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!ho95b!wcs From: wcs@ho95b.UUCP (Bill Stewart) Newsgroups: net.unix Subject: Why do people use: if [ "x$FOO" = "x" ] .... ? Message-ID: <361@ho95b.UUCP> Date: Tue, 9-Apr-85 00:37:49 EST Article-I.D.: ho95b.361 Posted: Tue Apr 9 00:37:49 1985 Date-Received: Tue, 9-Apr-85 08:41:00 EST Organization: AT&T Bell Labs, Holmdel NJ Lines: 20 I've seen a lot of Bourne shell scripts that test for blank variables using the construct if [ "x$FOO" = "x" ] Why the x's? If you leave out the quotes, then the test dies if $FOO is empty, but why not just use if [ "$FOO" = "" ] or if [ -z "$FOO" ] I've seen this construct in new code as well as old, from reputable programmers. I've checked a few obscure cases like FOO='`echo You Lose!!`' but even they don't die. Is this just another superstition, like sync; sync; sync; or am I forgetting something stupid and obvious? Thanks; Bill Stewart, AT&T Bell Labs, Holmdel NJ {ihnp4,allegra,cbosg}!ho95c!wcs