On Wed, Nov 17, 2004 at 10:17:19PM -0500, Michael G Schwern <[EMAIL PROTECTED]>
wrote:
> On Wed, Nov 17, 2004 at 06:27:31PM +0000, Mike Guy wrote:
> > Michael G Schwern <[EMAIL PROTECTED]> wrote
> > > No, you've only got two args to play with. This is the equivalent
> > > 5.005-ism.
> > >
> > > open(REALPATH, "-|") || exec '/usr/bin/fullpath', '-t', $path;
> >
> > Except that you haven't covered error cases. More correct is
> >
> > open(REALPATH, qq(/usr/bin/fullpath -t "$path" |) )
>
> I specificly avoided that because it invokes a shell and thus opens
> potential security and quoting problems (for example, double quoting the
> path is not what you want). The open || exec is closest to the 3+ arg open
> Ken was using and avoids invoking a shell.
>
> I also trust Ken to figure out the error handling. He's a big boy. ;)
But he posted a patch that didn't have it figured out. I assume the
error case that concerns Mike Guy here is "fork fails, but exec
succeeds".
So something like:
my $pid = open(REALPATH, "-|");
if (! $pid) {
exec('/usr/bin/fullpath', '-t', $path) if defined $pid;
die "Can't open /usr/bin/fullpath: $!";
}