From owner-freebsd-questions Sat May 3 10:11:34 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id KAA05305 for questions-outgoing; Sat, 3 May 1997 10:11:34 -0700 (PDT) Received: from bsd.fs.bauing.th-darmstadt.de (bsd.fs.bauing.th-darmstadt.de [130.83.63.241]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id KAA05298 for ; Sat, 3 May 1997 10:11:31 -0700 (PDT) Received: from campa.panke.de (anonymous220.ppp.cs.tu-berlin.de [130.149.17.220]) by bsd.fs.bauing.th-darmstadt.de (8.8.5/8.8.5) with ESMTP id TAA03744; Sat, 3 May 1997 19:11:26 +0200 (MET DST) Received: (from wosch@localhost) by campa.panke.de (8.8.5/8.6.12) id QAA02810; Sat, 3 May 1997 16:20:38 +0200 (MET DST) To: Steve Howe Cc: freebsd-questions Subject: Re: test -f $shvar References: From: Wolfram Schneider Date: 03 May 1997 16:20:35 +0200 In-Reply-To: Steve Howe's message of Sat, 3 May 1997 02:41:57 -0800 (AKDT) Message-ID: Lines: 26 Sender: owner-questions@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk Steve Howe writes: > anyone notice how "test -f $shvar" always results in "true"? This happens if the variable `shvar' is empty. This is correct because test(1) got only one argument and assume `-f' is a non-empty string and not the option `-f file'. $ man test string True if string is not the null string. > whether the file exists or not, the test is always true? test did not got a file. > i don't really understand why this is! is it a bug? The programmer must check if the variable `shvar' is not empty. E.g.: test -n "$shvar" -a -f "$shvar" -- Wolfram Schneider http://www.apfel.de/~wosch/