From owner-freebsd-questions Wed Sep 11 14:38:15 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0F84737B400 for ; Wed, 11 Sep 2002 14:38:12 -0700 (PDT) Received: from gate.raffles-it.com (raffles.demon.co.uk [62.49.18.137]) by mx1.FreeBSD.org (Postfix) with ESMTP id B7BEF43E3B for ; Wed, 11 Sep 2002 14:38:09 -0700 (PDT) (envelope-from dpd@raffles-it.com) Received: from arrow.lan.raffles-it.com (localhost [127.0.0.1]) by gate.raffles-it.com (8.12.5/8.12.5) with ESMTP id g8BLYqXo010938; Wed, 11 Sep 2002 22:34:52 +0100 (BST) (envelope-from dpd@lan.raffles-it.com) Received: (from dpd@localhost) by arrow.lan.raffles-it.com (8.12.6/8.12.6/Submit) id g8BLYpFi010937; Wed, 11 Sep 2002 22:34:51 +0100 (BST) Date: Wed, 11 Sep 2002 22:34:51 +0100 From: David Dooley To: David.Dooley@E-Peopleserve.com, freebsd-questions@freebsd.org Subject: KSH Shell Script Logic problem Message-Id: <20020911223451.2903ba62.dpd@raffles-it.com> X-Mailer: Sylpheed version 0.8.0claws (GTK+ 1.2.10; i386-portbld-freebsd4.6) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 Hi, I am trying to write a shell script using the ksh. a section of the script goes as follows, variables changed to protect the innocent :-) # Input file will have 2 elements per line seperated by a colon (:), # one or other element may be empty IFS=\: # Read line from file assign first element to VariableA and the # second element to VariableB cat config_file | while read VariableA VariableB do # Make sure that VariableA and B are assigned a value, if # nothing was read from the input, that can be checked, # so we are not mucking around and trying to do test's # with NULL's. VariableA=${VariableA:=UNSET} VariableB=${VariableB:=UNSET} [[ ${VariableA} != UNSET && ${VariableB} != UNSET ]] && { call function # check return code [[ ${?} -ne 0 ]] && { Echo Diagnostic error message } } || { [[ ${VariableA} != literal || \ ${VariableB} != literal ]] && { Echo diagnostic error message } } done In this scenario if [[ ${VariableA} != UNSET && ${VariableB} != UNSET ]] evaluates to true and we drop into the '&&' part of the test, and if the nested second test evaluates to true all is happy and right with the world, but if the second nested test fails then the outer test's '||' part is run, but if I put an '||' part on to the nested test to catch that failure then the first tests '||' part is not run, please could some one tell me why with out the nested tests '||', I get the outer tests '||' part run. I really hope that the previous paragraph makes sense, It only just about makes sense to me and I wrote it. Please could you include me on any answers as I am not subscriped to the list from this email address, thanks for your time and any assistance. David. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message