> Tobias Gasser schrieb am 05.06.2012 um 15:57 Uhr: > ... > btw: $PIPESTATUS is an ARRAY!! > to get all exit codes use ... ; echo ${PIPESTATUS[@]} > thus your $PIPESTATUS will be ${PIPESTATUS[0]} the exitcode from ls > which exits with 141 whenever the output is piped and the pipe > terminates while ls still writes to the pipe. > Have a look at tldp.org/LDP/abs/html/internalvariables.html > and search for PIPESTATUS.
Hi Tobias, Thank you very much for your insights. We're converging but not there yet. In the following, I'll redo my OP by hitting the main ideas from a different angle. Nothing additional, nothing original. Just a different angle. - The PIPESTATUS notion, while important and fascinating in itself, is only tertiary to my question here. I used it more for looks, and "balance". To me, 141 or 141.372 don't mean a thing in this particular experiment. I little aside if I may (while staying on topic). Recently, in my neck of the woods, there's been a rash of burglaries with an added twist. Normally, you break into a house and quickly grab the usuals - valuables (jewelries, etc.) and electronics. Nothing wrong with that; that's been standard procedure for hundreds of years (just that the electronics are more prevalent, sophisticated, expensive and smaller now). However, what's new and annoying is they also steal whatever copper pipes they can lay their hands on (a bash pipe mutation of some sort?). As you can imagine, that leaves the PIPESTATUS array of the house in terrible shape, at least Error 141, if not higher. A very important (and unavoidable) parameter in this case. Unfortunately. - My main (and only) question has been how I can maintain the main stream going (represented by 'ls' in my simulation; git, wget, etc., more realistically) if one of the pipe processes terminates (exits) _early_ - naturally or unnaturally. - I included the 'wc' "tee" just to show that if another process in another "tee" exits, it drags such an innocent and nicely running thing to the early grave with it (and that along with the main stream!). - It's easy to imagine in other programming languages starting some sub-processes to "monitor" the main stream, and doing their thing at their own leisure. If one or all exit early, in good shape or bad, good riddance. So be it. The stream integrity, visualizing and monitoring it (like the "grep -m" example) is my main concern. - The reason for my pleading for help has been that _other_ than some crazy switches to the main process (like 'ls') and/or to the culprits ('grep'), I feel that THERE MUST BE a clean way to do it in bash where the main stream can run to its natural completion unaffected by what goes on beyond (to the right of) the TEE (the 'tee' command). Maybe it can (and must) be done without 'tee' altogether. Who knows? Cheers, -- Alex -- http://linuxfromscratch.org/mailman/listinfo/blfs-support FAQ: http://www.linuxfromscratch.org/blfs/faq.html Unsubscribe: See the above information page