# New Ticket Created by  Joshua Hoblitt 
# Please include the string:  [perl #37673]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=37673 >


This transaction appears to have no content
----- Forwarded message from Fran?ois PERRAD <[EMAIL PROTECTED]> -----

From: Fran?ois PERRAD <[EMAIL PROTECTED]>
Date: Tue, 25 Oct 2005 06:31:43 +0200
To: perl6-internals@perl.org
Subject: check_progs is not portable


The subroutine check_progs defined in lib/Parrot/Configure/Step.pm is not 
portable (doesn't work on MSWin32).
On MSWin32, the real filename of a program is prog.exe, prog.com, prog.bat 
or prog.cmd , so if -x 'prog' is not enough.

This subroutine is currently used by config/inter/lex.pl & yacc.pl.

I suggest the use of the module File::Which (see the attached patch).
But I don't know if everybody is agree to depend of this module.

Fran?ois



----- End forwarded message -----
Index: lib/Parrot/Configure/Step.pm
===================================================================
--- lib/Parrot/Configure/Step.pm        (r????vision 9543)
+++ lib/Parrot/Configure/Step.pm        (copie de travail)
@@ -29,6 +29,7 @@
 use File::Basename qw( basename );
 use File::Copy ();
 use File::Spec;
+use File::Which;
 
 use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
 
@@ -487,22 +488,16 @@
 
     print "checking for program: ", join(" or ", @$progs), "\n" if $verbose;
     foreach my $prog (@$progs) {
-        # try relative path first in case it's not in the path
-        return $prog if -x $prog;
-
-        my $util = basename($prog);
+        my $util = $prog;
         # use the first word in the string to ignore any options
         ($util) = $util =~ /(\w+)/;
-        foreach my $dir (File::Spec->path) {
-            my $path = File::Spec->catfile($dir, $util);
+        my $path = which($util);
 
-            if ($verbose) {
-                print "trying: $path\n";
-                print "$path is executable\n" if -x $path;
-            }
-
-            return $prog if -x $path;
+        if ($verbose) {
+            print "$path is executable\n" if $path;
         }
+
+        return $prog if $path;
     }
 
     return;

Attachment: pgpF4gqchHabR.pgp
Description: PGP signature

Reply via email to