Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: Util/helpfiles failing on old-fashioned unix



Wayne Davison <wayned@xxxxxxxxxxxxxxxxxxxxx> wrote:
> vaeth@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>
>> Unfortunately, I do not know a way in perl to redirect stdin *and* stdout
>> of a subprocess simultaneously.
>>
>
> One easy way is to use IPC::Open3 <http://perldoc.perl.org/IPC/Open3.html>,
> which is a default library that comes with perl.  This lets you start a
> subprocess with any desired stdin & stdout & stderr.

Thanks. However, from the avoidance of the perl5 keyword "my" in
Util/helpfiles (and falling back to e.g. local) I guess that this
script is supposed to run even on historical perl{3,4} variants
where libraries can hardly be expected.
Looking at the implementation of IPC::Open3, I see that everything
is setup manually using e.g. "pipe" and "fork". The latter,
unsurprisingly, is not implemented on all systems.

Summarizing, I think that the posted solution with tempfiles is
more compatible, since its "system" call should work even in
non-multitasking environments (and does not need a cumbersome
implementation to make it work with historical perl variants).
It was intentional that the implementation used no library
(neither File::Temp::tempfile to produce the temporary file nor
File::Spec::catfile to concatenate directory and filename).
I even refrained from quoting the directories (hence, spaces
in the "help" directory name would cause trouble) to not rely
too much on the underlying shell used by perl.



Messages sorted by: Reverse Date, Date, Thread, Author