-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, 11 Mar 2002, Michael G Schwern wrote:

[finding location of perl binary]

>>The only safe and portable way to do this is the multi-argument form of
>>system().

>Try It!  find_perl() in ExtUtils::Win32 (the code above).  Gimme a
>patch.

Okay.  The patch you suggested, quoting spaces with backslashes, does
not work because Win2k's command shell doesn't grok backslashes.  Here's
my patch:

- --- MM_Win32.pm       Tue Sep  4 14:24:00 2001
+++ MM_Win32.pm.new     Wed Mar 13 11:45:30 2002
@@ -160,8 +160,26 @@
            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;" 2>&1`;
- -         if ($? == 0) {
+
+            my $tmp_out = 'out.tmp';
+            if ($trace < 2) {
+                # Hide stdout and stderr.
+                open(OLDOUT, '>&STDOUT') or die "cannot dup stdout: $!";
+                open(OLDERR, '>&STDERR') or die "cannot dup stderr: $!";
+                open(STDOUT, ">$tmp_out")
+                  or die "cannot write to $tmp_out: $!";
+                open(STDERR, ">$tmp_out")
+                  or die "cannot write to $tmp_out: $!";
+            }
+            my $ok = not system($abs, '-e', "require $ver;");
+            if ($trace < 2) {
+                open(STDERR, '>&OLDERR')
+                  or die "cannot dup stderr back again: $!";
+                open(STDOUT, '>&OLDOUT')
+                  or die "cannot dup stdout back again: $!";
+            }
+
+            if ($ok) {
                print "Using PERL=$abs\n" if $trace;
                return $abs;
            } elsif ($trace >= 2) {


But I think this code would better be shared among several MM_x files
rather than just for Win32.  Perhaps MM_Unix could hold it and MM_Win32
could inherit it somehow?  I don't know how all this stuff works.  The
present MM_Unix implementation is slightly different to Win32's but I
think this code should work for both.

>>It might be a good idea to make the code taint-clean,

>Yes.  After that we'll be unifying Gravity and Electromagnetism and
>then World Peace will be brought about just after supper. :)

I just suggest it as a debugging aid, not as a new feature to implement.
You can turn on -T, fix a couple of things that break and thus hopefully
a couple of quoting bugs, and then turn -T off again to continue with
normal development.  After world peace is achieved, of course, the code
can be distributed with -T set.

- -- 
Ed Avis <[EMAIL PROTECTED]>
Finger for PGP key


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8jz5GIMp73jhGogoRAs0wAKCEGJnXGr91NWHegMoVeW7yGMkBjgCfcrj/
Vq2O5Y3vMZ/vZyUFA2DpRiI=
=/zGI
-----END PGP SIGNATURE-----

Reply via email to