Re: Fascinating problem with bash
On Tue August 24 2010 04:09:39 Oliver Schneider wrote:
> Okay, that is surprising indeed, as SHLVL is not being adjusted to reflect
> that fact, according to my findings. But thanks a bunch for pointing that
> out. It's surely more elegant to use this method than to write to a
> temporary file.
You might be able to achieve your objective by returning an exit code
from the last pipeline element's process and then subsequently testing
it in the main script's process.
$ echo X | while read a; do echo $a; exit 1; done | while read b; do echo $b;
exit 2; done; echo $?
X
2
In many cases this can be simplified to a simple "&&" or "||".
--Mike Bird
Reply to: