Pierre Labastie wrote: > On 17/04/2017 15:10, Jeremy Henty wrote: > > Pierre Labastie wrote: > > > > > First the &&: an instruction such as: > > > do_this && do_that > > > in bash does not fail, even if "do_this" fails, because it is taken > > > by bash as semantically identical to: > > > if do_this; then do_that; fi > > This is not correct because the exit status may be different: > > > > $ false && true ; echo $? > > 1 > > $ if false ; then true ; fi ; echo $? > > 0 > > Oh you are right, thanks for the clarification. It is only when > using set -e that it works like that.
Thank you in return! I never thought to consider the effects of "set -e". In fact "set -e" makes things even stranger. I thought that "this && that" was equivalent to "if this ; then that ; else false ; fi", but after "set -e", "false && true" returns status 1 to the shell, but "if false ; then true ; else false ; fi" makes the shell itself exit with status 1! Is there no end to the "joy" of shell programming! :-) Thanks for an enlightening discussion. Jeremy Henty -- http://lists.linuxfromscratch.org/listinfo/blfs-support FAQ: http://www.linuxfromscratch.org/blfs/faq.html Unsubscribe: See the above information page
