From owner-freebsd-questions Tue May 6 09:04:25 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id JAA18263 for questions-outgoing; Tue, 6 May 1997 09:04:25 -0700 (PDT) Received: from iceberg.anchorage.net. (root@iceberg.anchorage.net [207.14.72.150]) by hub.freebsd.org (8.8.5/8.8.5) with SMTP id JAA18253 for ; Tue, 6 May 1997 09:04:22 -0700 (PDT) Received: from aak.anchorage.net (ai-129 [207.14.72.129]) by iceberg.anchorage.net. (8.6.11/8.7.3) with SMTP id HAA02785 for ; Tue, 6 May 1997 07:01:00 -0800 Date: Tue, 6 May 1997 07:54:44 -0800 (AKDT) From: Steve Howe X-Sender: abc@aak.anchorage.net To: freebsd-questions Subject: tests Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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!