On 13 May 2011 16:23, Robert Klemme <shortcutter / googlemail.com> wrote:
> On Fri, May 13, 2011 at 3:27 PM, Michal Suchanek <hramrach / centrum.cz> wrote:
>> On 13 May 2011 10:44, Robert Klemme <shortcutter / googlemail.com> wrote:
>>> On Thu, May 12, 2011 at 6:05 PM, Michal Suchanek <hramrach / centrum.cz> wrote:
>>>> how do you write an equivalent of
>>>>
>>>> $ cmdA | cmdB | cmdC
>>>>
>>>> in Ruby?
>>>>
>>>> Specifically, I would like to see the PID, return value and stderr of
>>>> each of these commands but I would like cmdB to read the stdout of
>>>> cmdA directly, on its stdin, and similarily for cmdC and cmdB.
>>>>
>>>> Here I am not interested in feeding cmdA some particular input (eg. it
>>>> can read /dev/null for all I care) but in general gluing arbitrary fd
>>>> to its stdin might be desirable in other cases.
>>>
>>> $ ri Open3.pipeline_r Open3.pipeline_start
>>>
>> Again, like in Open3.pipeline the :err argument used in the example is
>> not documented.
>
> Not true. From ri Open3.pipeline_r in 1.9.2p180:
>
> Each cmd is a string or an array. If it is an array, the elements are passed
> to Process.spawn.
>
> cmd:
>  commandline              command line stringwhich
> is passed to a shell
>  [env, commandline, opts]         command line string which
> is passed to a shell
>  [env, cmdname, arg1, ..., opts]     command name and one or
> more arguments (no shell)
>  [env, [cmdname, argv0], arg1, ..., opts] command name and
> arguments including argv[0] (no shell)
>
> Note that env and opts are optional, as Process.spawn.
>
> Then
>
> $ ri Process.spawn
>

It's not quite clear that Process.spawn description also applies to
options outside the commands and how it applies but maybe it makes
sense, they would be applied to the whole pipeline.

Thanks

Michal