Hi Bob, thanks for your response. Comments below ...
> diff <(process1) <(process2) That works great for most purposes ! Thanks for reminding of this syntax. But how would I make the open FDs available to a sub-shell? e.g. how would I say : ( read 63>&1 ; ... ; read 62>&1 ; ... ) <(...) <(...) e.g. this gives me syntax error : ( read 63>&1 ; read 62>&1 ) <(ls) <(ls -L) Thx, John aside: Do you know whether there is a way to *switch* two descriptors (like stdout / stderr) ? I.e. the intuitive '( ls -d / /asdfasdf 1>&2 2>&1 ) >err 2>out' doesn't work. On Sat, 30 Aug 2003, Bob Proulx wrote: > Date: Sat, 30 Aug 2003 21:14:54 -0600 > From: Bob Proulx <[EMAIL PROTECTED]> > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED] > Subject: Re: multiple inputs / outputs through descriptors > > [EMAIL PROTECTED] wrote: > > Since I didn't find textutils / coreutils discussion list > > (only coreutils-announce), and this is more of a technical > > implementation / feature issue, I'm writing this into > > bug-textutils. Please forward / repost where appropriate or > > let me know. > > You have sent your note go a reasonable place. But for the future > here is the documentation you were looking for. > > http://www.gnu.org/software/coreutils/ > > > Standardize throughout GNU utils (just like long options > > have been standardized) a descriptor input / output syntax. > > In the old days '-' was considered the standard for stdin and stdout. > Look at 'tar' for one example. (e.g. 'gunzip file.tar.gz | tar tvf -') > But that is "in-band control" and creates the possibility of name > conflicts. > > > e.g. I could write (in bash) something like this : > > > > ( process1 --output 3>&1 ; process2 --output 4>&1 ) | diff --input-file %3% > > --input-file %4% > > Yes, that is ugly. How about using bash's process substitution? > > Process Substitution > Process substitution is supported on systems that support > named pipes (FIFOs) or the /dev/fd method of naming open > files. It takes the form of <(list) or >(list). The pro- > cess list is run with its input or output connected to a > FIFO or some file in /dev/fd. The name of this file is > passed as an argument to the current command as the result > of the expansion. If the >(list) form is used, writing to > the file will provide input for list. If the <(list) form > is used, the file passed as an argument should be read to > obtain the output of list. > > Then your above example looks like this. This looks much cleaner to > me. > > diff <(process1) <(process2) > > Here is a real example you can try. > > diff -u <(printf "foo\nbar\n") <(printf "baz\nbar\n") > > --- /tmp/sh-np-a20909 Sat Aug 30 20:59:55 2003 > +++ /tmp/sh-np-b20909 Sat Aug 30 20:59:55 2003 > @@ -1,2 +1,2 @@ > -foo > +baz > bar > > This works even on my ancient HP-UX 10.20 machine upon which I tested > this example. As long as the system supports named pipes this is > available. Newer systems with /dev/fd are even better. But I don't > believe this is specified by POSIX and so should be considered a bash > only feature. But I say that not knowing if other shells support it > or not. Just that it is not a POSIX /bin/sh feature. > > Bob > -- -- Gospel of Jesus' kingdom = saving power of God for all who believe -- ## To some, nothing is impossible. ## _______________________________________________ Bug-textutils mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-textutils