From owner-freebsd-questions Wed Apr 3 14: 8:57 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mailsrv.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by hub.freebsd.org (Postfix) with ESMTP id 8E1DE37B417 for ; Wed, 3 Apr 2002 14:08:50 -0800 (PST) Received: from hades.hell.gr (patr530-b233.otenet.gr [212.205.244.241]) by mailsrv.otenet.gr (8.12.2/8.12.2) with ESMTP id g33M8jbP019340; Thu, 4 Apr 2002 01:08:46 +0300 (EEST) Received: from hades.hell.gr (hades [127.0.0.1]) by hades.hell.gr (8.12.2/8.12.2) with ESMTP id g33M8ecq003031; Thu, 4 Apr 2002 01:08:53 +0300 (EEST) (envelope-from keramida@freebsd.org) Received: (from charon@localhost) by hades.hell.gr (8.12.2/8.12.2/Submit) id g33L6LQv002501; Thu, 4 Apr 2002 00:06:21 +0300 (EEST) (envelope-from keramida@freebsd.org) Date: Thu, 4 Apr 2002 00:06:21 +0300 From: Giorgos Keramidas To: Glenn Johnson Cc: questions@freebsd.org Subject: Re: why does this test condition not work? Message-ID: <20020403210621.GH848@hades.hell.gr> References: <20020403172111.GA88600@node1.cluster.srrc.usda.gov> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020403172111.GA88600@node1.cluster.srrc.usda.gov> User-Agent: Mutt/1.3.28i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On 2002-04-03 11:21, Glenn Johnson wrote: > I am writing a script am am trying to prompt for input and make sure all > of the values are entered. I have the following test condition in my > script but when I run it I get: > > [: -z: unexpected operator > while [ -z $tor1a -o -z $tor1b -o -z $tor1c -o -z $tor1d ] > do > read -p "Enter the atom numbers of the first torsion: " tor1a > tor1b tor1c tor1d > done Because at first all of your variables are unset, and the test within brackets is expanded by sh to: [ -z -o -z -o -z -o -z ] The first -o is consumed by the previous -z, and then test(1) moves on to check the rest of it's arguments and finds a -z (the second -z) where it would expect -or or -and. Try this instead: while [ -z "$tor1a" -o -z "$tor1b" -o -z "$tor1c" -o -z "$tor1c" ] do echo -n "Enter the atom numbers of the first torsion: " read tor1a to1b tor1c tor1d done Giorgos Keramidas FreeBSD Documentation Project keramida@{freebsd.org,ceid.upatras.gr} http://www.FreeBSD.org/docproj/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message