From: Paul Green Date: Fri, 31 May 2002 12:23:00 +0000 (-0400) Subject: Adjust executable suffix checks for VMS X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=68fb0eb7ecdd3258dde75aba3e98109bd2bcc6c3;p=p5sagit%2Fp5-mst-13.2.git Adjust executable suffix checks for VMS Message-Id: <200205311622.MAA21673@mailhub2.stratus.com> p4raw-id: //depot/perl@16927 --- diff --git a/pod/perlport.pod b/pod/perlport.pod index 2b4d3d9..a90d4cd 100644 --- a/pod/perlport.pod +++ b/pod/perlport.pod @@ -453,30 +453,32 @@ Don't count on specific values of C<$!>. 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 +First, many systems have "internal" commands that are built-in to the +shell or OS and while these commands can be invoked, there is no +corresponding file. Second, some operating systems (e.g., 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. +if any. Third, the VMS port carefully sets up $^X and +$Config{perlpath} so that no further processing is required. This is +just as well, because the matching regular expression used below would +then have to deal with a possible trailing version number in the VMS +file name. 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; + if ($^O ne 'VMS') + {$thisperl .= $Config{_exe} unless $thisperl =~ m/$Config{_exe}$/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; + $thisperl = $Config{perlpath}; + if ($^O ne 'VMS') + {$thisperl .= $Config{_exe} unless $thisperl =~ m/$Config{_exe}$/i;} =head2 Interprocess Communication (IPC) diff --git a/pod/perlvar.pod b/pod/perlvar.pod index 9f23dcf..ae72617 100644 --- a/pod/perlvar.pod +++ b/pod/perlvar.pod @@ -1178,10 +1178,10 @@ following statements: # Build up a set of file names (not command names). use Config; - use File::Spec; - $this_perl = File::Spec->canonpath($^X); - $this_perl .= $Config{_ext} - unless $this_perl =~ m/$Config{_ext}([;\d]*)$/i; + $this_perl = $^X; + if ($^O ne 'VMS') + {$this_perl .= $Config{_exe} + unless $this_perl =~ m/$Config{_exe}$/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 @@ -1192,10 +1192,10 @@ this goal, and produce a pathname that can be invoked as a command or referenced as a file. use Config; - use File::Spec; - $secure_perl_path = File::Spec->canonpath($Config{perlpath}); - $secure_perl_path .= $Config{_ext} - unless $secure_perl_path =~ m/$Config{_ext}([;\d]*)$/i; + $secure_perl_path = $Config{perlpath}; + if ($^O ne 'VMS') + {$secure_perl_path .= $Config{_exe} + unless $secure_perl_path =~ m/$Config{_exe}$/i;} =item ARGV