Thanks for your answer, I managed to worked it out in the end with the help of this page
http://www.gnu.org/manual/bash-2.05a/html_node/bashref_18.html#SEC18 but I always like to end with a puzzle It reminds me of a puzzle my father asked me many years ago that I always like bringing up when there is a few mathematicians around. It goes something like this A farmer has a round field, radius (r) he wants to tether a goat (g) to a point on the edge of the field (t) so that the goat can clear half of the field how long should the tether be? its obvious that tg > r but what is the ratio ? I'm sure you math type people will get it. On Thu, 2002-10-10 at 22:58, [EMAIL PROTECTED] wrote: > On Thu, Oct 10, 2002 at 12:25:25PM +0930, Mark Bradbury wrote: > > Any bash shell masters out there? > > > > Can someone explain why the statement > > false && true && echo 1 || true && false && echo 2 || false || true || echo 3 && >echo 4 && echo 5 > > > > prints out > > 4 > > 5 > > > > and not > > 3 > > 4 > > 5 > > > > Its an old trick, Any && expression stops evaluation at the first false > value it gets, any || expression stops at the first true value it gets. > (&& = AND, || = OR ) > > So the only part you have to look at is: > > true || echo 3 && echo 4 && echo 5 > > Which is better understood as : ( true || echo 3) && (echo 4 && echo 5) > or (X) && (Y) > > As soon as "true" is encountered in (X) it stops evaluating that part > of the statement, (so the "echo 3" is never evaluated), and goes to the > && separating the two paren groups. Since its an && statement the (Y) > has to be evaluated to determine if the entire statement is true. > > Since the (Y) expression is also an "AND" statement both subexpressions > "echo 4" and "echo 5" have to be evaluated. > > Next question - How does bash determine precedence in an expression ? > (critical to the above... ) > > > -- > Jeff Kinz, Director, Emergent Research, Hudson, MA. "[EMAIL PROTECTED]" > "[EMAIL PROTECTED]" copyright 2002. Use is restricted. Any use is an > acceptance of the offer at http://users.rcn.com/jkinz/policy.html. > > (o- -o) > //\ eLviintuaxbilse /\\ > V_/_ _\_V > > > > -- > redhat-list mailing list > unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe > https://listman.redhat.com/mailman/listinfo/redhat-list -- - Mark Bradbury Email: [EMAIL PROTECTED] Web Engineer Teaching & Learning Support Phone: +61 8 89467776 Northern Territory University Mobile: 0417 860 591 Casuarina 0909 Australia Fax: +61 8 89466630 -- redhat-list mailing list unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe https://listman.redhat.com/mailman/listinfo/redhat-list