On Mar 12, 2012, at 2:26 PM, Aaron Davies wrote:
> On Mar 12, 2012, at 1:20 PM, David Korn <[email protected]> wrote:
>
>> Another alternative is
>> find ... | while read -u5 f ; do ... done 5<&0-
>>
>> This will also run faster since the shell is able to do full buffer
>> reads on file descriptor 5 since it is not shared.
>
> one additional question tho--is it possible to invoke something inside the
> while loop with a stdin of its own, separate from the one used by while and
> read? at the moment, commands inside the while loop seem to have no 0 fd at
> all
>
> (if you're curious, what I'm invoking inside the loop is an interpreter
> script which will drop me into a REPL if an error occurs, but only if stdin
> is available)
actually i think i've got this one more or less figured out--swapping the fd's
around repeatedly seems to do what i need
exec {stdin}<&0-
find .. | while read -u$fd; do
exec 0<&$stdin-
..
exec {stdin}<&0-
done {fd}<&0-
exec {fd}>&-
unset fd
exec 0<&$stdin-
--
Aaron Davies
[email protected]
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users