On Wed, Nov 13, 2002 at 03:32:52PM -0500, Michael G Schwern wrote: > Unfortunately, this still leaves the sticky problem of trapping STDERR on > Win9X. 2>&1 doesn't work. This does: > > $val = `"$abs" -e "close STDERR; require $ver"; print "VER_OK\n"` > > but that assumes $abs is actually perl and the program runs and exits > normally. We might have to go with Ed's idea of duping and closing STDERR > before running the command, which isn't so bad.
Ok, here's what's gone in. It should solve both the 2>&1 problem on Win9X and the C:\Program Files\perl\bin\perl problem, at least in find_perl(). This means MM_Win32->find_perl can go away. Snapshots on makemaker.org. Index: lib/ExtUtils/MM_Unix.pm =================================================================== RCS file: /home/cvs/ExtUtils-MakeMaker/lib/ExtUtils/MM_Unix.pm,v retrieving revision 1.82 retrieving revision 1.83 diff -b -u -r1.82 -r1.83 --- lib/ExtUtils/MM_Unix.pm 13 Nov 2002 11:19:48 -0000 1.82 +++ lib/ExtUtils/MM_Unix.pm 13 Nov 2002 22:03:03 -0000 1.83 @@ -1070,13 +1070,26 @@ @$dirs "; } + + my $stderr_duped = 0; + if( open(STDERR_COPY, '>&STDERR') ) { + $stderr_duped = 1; + } + else { + warn <<WARNING; +find_perl() can't dup STDERR: $! +You might see some garbage while we search for Perl +WARNING + } + foreach $name (@$names){ foreach $dir (@$dirs){ next unless defined $dir; # $self->{PERL_SRC} may be undefined my ($abs, $val); if (File::Spec->file_name_is_absolute($name)) { # /foo/bar $abs = $name; - } elsif (File::Spec->canonpath($name) eq File::Spec->canonpath(basename($name))) { # foo + } elsif (File::Spec->canonpath($name) eq + File::Spec->canonpath(basename($name))) { # foo $abs = $self->catfile($dir, $name); } else { # foo/bar $abs = $self->catfile($Curdir, $name); @@ -1084,12 +1097,18 @@ print "Checking $abs\n" if ($trace >= 2); next unless $self->maybe_command($abs); print "Executing $abs\n" if ($trace >= 2); - $val = `$abs -e 'require $ver; print "VER_OK\n" ' 2>&1`; - if ($val =~ /VER_OK/) { + + # To avoid using the unportable 2>&1 to supress STDERR, + # we close it before running the command. + close STDERR if $stderr_duped; + $val = `"$abs" -e "require $ver; print qq{VER_OK\n}"`; + open STDERR, '>&STDERR_COPY' if $stderr_duped; + + if ($val =~ /^VER_OK/) { print "Using PERL=$abs\n" if $trace; return $abs; } elsif ($trace >= 2) { - print "Result: `$val'\n"; + print "Result: '$val'\n"; } } } -- Michael G. Schwern <[EMAIL PROTECTED]> http://www.pobox.com/~schwern/ Perl Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One One disease, long life. No disease, short life.