From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12894 invoked by alias); 14 Dec 2013 09:23:45 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 32107 Received: (qmail 20877 invoked from network); 14 Dec 2013 09:23:30 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 X-Injected-Via-Gmane: http://gmane.org/ To: zsh-workers@zsh.org From: Martin Vaeth Subject: Re: PATCH: Util/helpfiles failing on old-fashioned unix Date: Sat, 14 Dec 2013 09:23:02 +0000 (UTC) Message-ID: References: <20131123174827.249f9678@pws-pc.ntlworld.com> <131123114714.ZM18477@torch.brasslantern.com> <131123210612.ZM31978@torch.brasslantern.com> <20131124175649.27c2559a@pws!> <-pc.ntlworld.com@samsung.com> <131125001818.ZM26494@torch.brasslantern.com> <691AC9C6-D832-42FC-B983-60C682AA5515@kba.biglobe.ne.jp> <20131125154954.14283de2@pwslap01u.europe.root.pri> <131125085631.ZM17483@torch.brasslantern.com> <20131212221744.GA27563@ma.sdf.org> Reply-To: vaeth@mathematik.uni-wuerzburg.de X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: lounge.imp.fu-berlin.de User-Agent: slrn/pre1.0.0-26 (Linux) Wayne Davison wrote: > vaeth@mathematik.uni-wuerzburg.de> 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 , > 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.