From: Paul Green Date: Thu, 30 May 2002 17:32:00 +0000 (-0400) Subject: Improved $^X patch X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a10d74f301e9c83108aa701b20914b6bb55d9310;p=p5sagit%2Fp5-mst-13.2.git Improved $^X patch Message-Id: <200205302132.RAA18437@mailhub1.stratus.com> p4raw-id: //depot/perl@16912 --- diff --git a/Configure b/Configure index a419c6e..87275ce 100755 --- a/Configure +++ b/Configure @@ -20,7 +20,7 @@ # $Id: Head.U,v 3.0.1.9 1997/02/28 15:02:09 ram Exp $ # -# Generated on Thu May 30 16:44:56 EET DST 2002 [metaconfig 3.0 PL70] +# Generated on Fri May 31 05:20:00 EET DST 2002 [metaconfig 3.0 PL70] # (with additional metaconfig patches by perlbug@perl.org) cat >c1$$ <. +=head2 Command names versus file pathnames + +Don't assume that the name used to invoke a command or program with +C or C can also be used to test for the existence of the +file that holds the executable code for that command or program. +First, many operating systems have "internal" commands that are +built-in to the OS and while these commands can be invoked, there is +no corresponding file. Second, some operating systems (Cygwin, DJGPP, +OS/2, and VOS) have required suffixes for executable files; these +suffixes are generally permitted on the command name but are not +required. Thus, a command like "perl" might exist in a file named +"perl", "perl.exe", or "perl.pm", depending on the operating system. +The variable "_exe" in the Config module holds the executable suffix, +if any. Third, VMS files always end in a version number, which comes +after the executable suffix. + +To convert $^X to a file pathname, taking account of the requirements +of the various operating system possibilities, say: + use Config; + use File::Spec; + $thisperl = $^X; + $thisperl .= $Config{_exe} unless $thisperl ~= m/$Config{_exe}([;\d]*)$/i; + +To convert $Config{perlpath} to a file pathname, say: + + use Config; + use File::Spec; + $thisperl = File::Spec->canonpath($Config{perlpath}); + $thisperl .= $Config{_exe} unless $thisperl ~= m/$Config{_exe}([;\d]*)$/i; + =head2 Interprocess Communication (IPC) In general, don't directly access the system in code meant to be diff --git a/pod/perlvar.pod b/pod/perlvar.pod index bf1d765..9f23dcf 100644 --- a/pod/perlvar.pod +++ b/pod/perlvar.pod @@ -1158,7 +1158,8 @@ a relative or absolute pathname of the perl program file, or may be the string used to invoke perl but not the pathname of the perl program file. Also, most operating systems permit invoking programs that are not in the PATH environment variable, so there -is no guarantee that the value of $^X is in PATH. +is no guarantee that the value of $^X is in PATH. For VMS, the +value may or may not include a version number. You usually can use the value of $^X to re-invoke an independent copy of the same perl that is currently running, e.g., @@ -1179,8 +1180,8 @@ following statements: use Config; use File::Spec; $this_perl = File::Spec->canonpath($^X); - $this_perl .= $Config{exe_ext} - unless $this_perl =~ m/$Config{exe_ext}$/i; + $this_perl .= $Config{_ext} + unless $this_perl =~ m/$Config{_ext}([;\d]*)$/i; Because many operating systems permit anyone with read access to the Perl program file to make a copy of it, patch the copy, and @@ -1193,8 +1194,8 @@ command or referenced as a file. use Config; use File::Spec; $secure_perl_path = File::Spec->canonpath($Config{perlpath}); - $secure_perl_path .= $Config{exe_ext} - unless $secure_perl_path =~ m/$Config{exe_ext}$/i; + $secure_perl_path .= $Config{_ext} + unless $secure_perl_path =~ m/$Config{_ext}([;\d]*)$/i; =item ARGV