Le Friday 11 September 2015 à 20:23 +0000, Thorsten Glaser a écrit : > Dixi quod… > > >I think coprocesses are pretty usable for this in almost all cases > >(I did have one where they weren’t, but you can still often background > >a part, then play with fd redirection). > > Another thing that may help you, if it’s absolutely needed: > > Before we had ${PIPESTATUS[*]} I wrote things like this: > > foo | (bar; echo $? >bar.rv) | baz > > Similarily, you can do tricks with high file descriptors. > > x=$( (echo foo | (tr a-z A-Z >&4) | (echo bla >&5)) 4>&1) 5>&1 > echo x=$x > > This gives: > > bla > x=FOO
"Nice" :] > Both not as efficient as direct variable assignment, but… > > And let's not forget using… > while …; do …; done <foo > … instead of… > cat foo | while …; do …; done > … (which is cat abuse anyway). Amen. I've been working with a lot of bash scripts and I yell each time I see the "cat foo |" construct. > Often, some not-so-basic or more modern scripting approaches > can eliminate the need for a construct like you were asking for. I will check with the customer. The example they provided was clearly made up to illustrate the problem (and I do appreciate when customers make the problem easy to understand) so I don't know exactly what their actually script is doing. -- Jean Delvare SUSE L3 Support