Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 Sep 1996 09:47:52 +0200 (MET DST)
From:      J Wunsch <j@uriah.heep.sax.de>
To:        freebsd-current@FreeBSD.org (FreeBSD-current users)
Cc:        jkh@time.cdrom.com (Jordan K. Hubbard), bde@zeta.org.au (Bruce Evans)
Subject:   Re: Anyone mind if I remove the following braindamage from test(1)?
Message-ID:  <199609020747.JAA22529@uriah.heep.sax.de>
In-Reply-To: <2893.841647826@time.cdrom.com> from "Jordan K. Hubbard" at "Sep 2, 96 00:03:46 am"

next in thread | previous in thread | raw e-mail | index | archive | help
As Jordan K. Hubbard wrote:

> And I still think it's a bug.  I don't see why "[ -f /tmp/i_exist ]"
> and "[ -f ]" should be treated identically.  I'd expect the opposite.

It's not a bug, it's a weird feature.  Any single argument is
considered to be the test for a string.  No such thing like ``option
flag'' for a single argument.  Thus:

read foobar
<User enters "-f" here.>

if [ "$foobar" ]
then
	:
else
	echo You fool!  You haven't entered anything!
	exit 1
fi

...works.

-- 
cheers, J"org

joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199609020747.JAA22529>