Date: Fri, 17 Jul 2009 19:21:14 -0600 From: Brett Glass <brett@lariat.net> To: aw1@stade.co.uk, chat@freebsd.org Subject: Re: Bourne shell short-circuit operators improperly documented Message-ID: <200907180121.TAA16416@lariat.net> In-Reply-To: <20090718000116.GA8379@steerpike.hanley.stade.co.uk> References: <200907172257.QAA15292@lariat.net> <20090718000116.GA8379@steerpike.hanley.stade.co.uk>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200907180121.TAA16416>