Date: Sat, 18 Jul 2009 01:01:16 +0100 From: Adrian Wontroba <aw1@stade.co.uk> To: chat@freebsd.org Subject: Re: Bourne shell short-circuit operators improperly documented Message-ID: <20090718000116.GA8379@steerpike.hanley.stade.co.uk> In-Reply-To: <200907172257.QAA15292@lariat.net> References: <200907172257.QAA15292@lariat.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Jul 17, 2009 at 04:57:12PM -0600, Brett Glass wrote: > Short-Circuit List Operators > ``&&'' and ``||'' are AND-OR list operators. ``&&'' executes the first > command, and then executes the second command if the exit status of the > first command is zero. ``||'' is similar, but executes the second com- > mand if the exit status of the first command is nonzero. ``&&'' and > ``||'' both have the same priority. > > This is exactly backward. 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. [aw1@steerpike ~]$ sh $ true && echo true true $ false || echo false false $ true; echo $? 0 $ false; echo $? 1 $ exit -- Adrian Wontroba Confused? You will be. Just watch ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090718000116.GA8379>