How do I chdir in an exec?
Nicholas Clark
nick at ccl4.org
Mon Mar 9 10:12:33 GMT 2009
On Sun, Mar 08, 2009 at 09:10:46PM -0400, David Golden wrote:
> On Sun, Mar 8, 2009 at 4:21 PM, Michael G Schwern <schwern at pobox.com> wrote:
> > A simple solution to this problem would seem to be allowing exec (or a new
> > option) to return a filehandle in place of a command to run.
> >
> > exec => sub {
> > ...derive $sub_module, $command and $file...
> >
> > chdir "ext/$sub_module";
> > open my $fh, "-|", $command, $file;
> > chdir "../..";
> >
> > return $fh;
> > }
> >
> > This gives the user complete control over the running of the test without
> > having to bail out to a separate script.
>
> Unfortunately, not portable. See perlport and open.
I think the solution to the portability issue is to subclass
TAP::Parser::Iterator::Process and provide setup() and teardown() methods to
do the directory changing.
As to the file handle proposal - that seems a useful addition to me, because
it's cleanly defined, and extensible in ways we've not yet thought of.
What am I missing?
Nicholas Clark
More information about the tapx-dev
mailing list