develooper Front page | perl.perl5.porters | Postings from May 2002

[PATCH] Adjust executable suffix checks for VMS

Thread Next
From:
Paul_GreenVOS
Date:
May 31, 2002 09:22
Subject:
[PATCH] Adjust executable suffix checks for VMS
Message ID:
200205311622.MAA21673@mailhub2.stratus.com
The following patch wordsmiths the language in perlport.pod
about internal commands, tries to explain why we want to leave
VMS path names alone, and then fixes the sample code to leave
VMS path names alone.

I decided in the same of simplicity to flush the reference to
File::Spec->canonpath, as I trust that the perl build process
should give us good clean data in $Config{perlpath}.

I corrected the typo found by Craig Berry re $Config{_ext} vs
$Config{_exe}.  [I knew I should have tested that code; now I
have, belatedly].

With the exception in place for VMS, the regular expression
returns to its old familiar self.

I think this patch addresses everyone's concerns.  Thank you to
everyone for helping get it right.

### START OF PATCH ###

diff -urp --new-file oldperl/pod/perlport.pod newperl/pod/perlport.pod
--- oldperl/pod/perlport.pod	Fri May 31 11:23:57 2002
+++ newperl/pod/perlport.pod	Fri May 31 12:13:54 2002
@@ -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<system> or C<exec> 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 -urp --new-file oldperl/pod/perlvar.pod newperl/pod/perlvar.pod
--- oldperl/pod/perlvar.pod	Fri May 31 11:24:25 2002
+++ newperl/pod/perlvar.pod	Fri May 31 12:13:09 2002
@@ -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 c
 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
 
### END OF PATCH ###

Thanks
PG
--
Paul Green                  | Mail: Paul.Green@stratus.com
Senior Technical Consultant | Voice: +1 978-461-7557   FAX: +1 978-461-3610
Stratus Technologies        | Video: PictureTel/AT&T by request.
Maynard, MA  01754          | Disclaimer: I speak for myself, not Stratus.


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About