On Thu, May 03, 2012 at 06:49:15PM -0400, Steve Scaffidi wrote:
> # This is so non-portable... I can't find a CPAN dist for this???
> sub __proc_path_from_fh {
> return
> $OSNAME =~ /Linux/i ? "/proc/self/fd/".fileno(shift) :
> $OSNAME =~ /MacOS|darwin/i ? "/dev/fd/".fileno(shift) :
> return;
> }
>
> On Tue, Apr 10, 2012 at 10:39 AM, Shlomi Fish <[email protected]> wrote:
> > Since this code also
> > only supports Linux and Mac OS X, I would suggest taking a look at the
> > source for GNU Bash and/or similar portable shells and see how they are
> > doing it. You may also wish to consider extracting this functionality into
> > its
> > own self-contained CPAN distribution.
They'll do it via some #defines and platform-specific code in their
./configure script.
No, I haven't looked to confirm this, but that's the obvious way to do
it in a C program. Doesn't really apply to perl, and what Steve's done
is pretty much the best you'll get if it's not in %Config (which it
isn't). Obviously it would be really nice if it could be abstracted
out into separate modules so that other people could use it.
I'm not sure where $OSNAME is coming from, but I'd recommend (for all
code, not just this module) using Devel::CheckOS instead of trying to
figure it out yourself, as even that seemingly simple check above has
at least one bug! The bug is that /MacOS/ is Mac OS *classic*, on
which this code doesn't have any chance at all of working.
--
David Cantrell | Enforcer, South London Linguistic Massive
Safety tip: never strap firearms to a hamster
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm