On Thursday, November 14, 2002, at 03:42  PM, Michael G Schwern wrote:

On Thu, Nov 14, 2002 at 02:21:35PM +1100, Ken Williams wrote:
@@ -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;
Is there no way to use the multi-arg system() to avoid these
quoting issues altogether?
Ed's original patch tried that.
http://archive.develooper.com/makemaker@;perl.org/msg00199.html

As you can see its more work and involves temp files (Ed's patch forgets to
cleanup after itself). And its incomplete since it would have to read the
output from the file to which STDOUT was redirected to make sure the VER_OK
was printed rather than just relying on the exit value as the more modern
version of find_perl() does. [1]

Oy, though. It's doing more work than it needs to. Why not just check the exit value?

my $ok = !system($abs, '-e', "exit !eval 'require $ver; 1'");


-Ken



Reply via email to