Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 May 1997 07:54:44 -0800 (AKDT)
From:      Steve Howe <un_x@anchorage.net>
To:        freebsd-questions <questions@freebsd.org>
Subject:   tests
Message-ID:  <Pine.BSF.3.95q.970506072104.11459A-100000@aak.anchorage.net>

next in thread | raw e-mail | index | archive | help

i guess this is the way "test"s work, in case
it gives anyone new to sh programming some troubles ...
------------------------------------------------------------------------
all integers are strings, but only numeric strings are "integers".

[ x ] only fails on the null string, ""(ascii 0), not on 0 (ascii 48).

any test, results in a 0(ascii 0) or 1(ascii 1).

! x is only true if x is ""(ascii 0), so it may only be used to
	test for the null string ("") and the result of a test([]).

therefore, -gt, -lt, -ge, -le may only be used on numeric strings,
	the "-" tests force a stringTOint conversion for the comparison,
	is my guess.

and so -eq/= and -ne/!= may be used interchangably, as long as you
	never use an alphabetic character in a -eq/-ne comparison,
	since a stringTOint conversion must be done w/ -ne and -eq..
-------------------------------------------------------------------------
i'm "fairly" sure this is correct!




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.95q.970506072104.11459A-100000>