From owner-freebsd-chat@FreeBSD.ORG Sat Jul 18 01:21:30 2009 Return-Path: Delivered-To: chat@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6BCAC1065673 for ; Sat, 18 Jul 2009 01:21:30 +0000 (UTC) (envelope-from brett@lariat.net) Received: from lariat.net (lariat.net [66.119.58.2]) by mx1.freebsd.org (Postfix) with ESMTP id 01C238FC1A for ; Sat, 18 Jul 2009 01:21:29 +0000 (UTC) (envelope-from brett@lariat.net) Received: from anne-o1dpaayth1.lariat.net (IDENT:ppp1000.lariat.net@lariat.net [66.119.58.2]) by lariat.net (8.9.3/8.9.3) with ESMTP id TAA16416; Fri, 17 Jul 2009 19:21:19 -0600 (MDT) Message-Id: <200907180121.TAA16416@lariat.net> X-Mailer: QUALCOMM Windows Eudora Version 7.1.0.9 Date: Fri, 17 Jul 2009 19:21:14 -0600 To: aw1@stade.co.uk, chat@freebsd.org From: Brett Glass In-Reply-To: <20090718000116.GA8379@steerpike.hanley.stade.co.uk> References: <200907172257.QAA15292@lariat.net> <20090718000116.GA8379@steerpike.hanley.stade.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Cc: Subject: Re: Bourne shell short-circuit operators improperly documented X-BeenThere: freebsd-chat@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Non technical items related to the community List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Jul 2009 01:21:30 -0000 At 06:01 PM 7/17/2009, Adrian Wontroba wrote: >No it is succinctly correct but confusing (the UNIX way?). These >operators work on exit codes where 0 = success = true and and !0 = >failure = false. As I understand it, when it comes to UNIX result codes, 0 doesn't really mean "true" -- it means "no error." (In other words, it means "false.") Whereas any nonzero value means there was an error (and indicates what kind). In other words, it means that it's "true" that there was an error. So, the semantics of the operators are supposed to be that "false" is "true?" Aaargh! No wonder I don't use short circuit operators much. When zero equals one, it gets rather confusing. It's also confusing that they are called "AND" and "OR" operators (and look like the short-circuit AND and OR operators in other languages, which all do what you would expect). --Brett