On Sun, Feb 10, 2013 at 07:30:32PM -0800, sfeam (Ethan Merritt) wrote:
> Could you explain the motivation for the patch?
> The example you give
>
> cat data-1 | ./src/gnuplot -p -e "plot '<&0', '<&3', '<&4'" 3<data-2 4<data-3
>
> seems entirely artificial since you could just as easily say
>
> gnuplot -p -e "plot data-1, data-2, data-3"
>
> Alternatively you could use named pipes, which also work already.
> So what, really, is the use case for this?
I often have data-generating programs that I want to run several times
with different parameters. I'd like to plot these with the same
gnuplot script. The changing parameters make '<myprogram -a 1 -b 2'
impossible without script edits, and the:
$ (cat plot.gp; myprogram -a 1 -b 2) | gnuplot
idiom scales poorly:
$ (cat plot.gp; myprogram -a 1 -b 2; cat plot-2.gp; myprogram -a 3 -b 4) | gnuplot
where the plotting script has to be split between plot.gp and
plot-2.gp to grab the subshell-inlined data.
With named pipes, you'd have something like:
$ mkfifo data-1
$ mkfifo data-2
$ gnuplot plot.gp
$ myprogram -a 1 -b 2 > data-1
$ myprogram -a 3 -b 4 > data-2
$ rm -f data-1 data-2
which is also not particularly elegant.
I'm used to file descriptor redirection in the shell, and it seemed
like a natural fit:
$ gnuplot plot.gp 3< <(myprogram -a 1 -b 2) 4< <(myprogram -a 3 -b 4)
This is basically the same as the named-pipe case, except that there
are no setup/teardown steps.
Thanks for taking a look :).
Trevor
--
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy
|