In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/cdd06489088cf64a0e621b79cdf0c48eb55f2622?hp=eeace61d181813f7b93c686e9d16cd914a90dd7d>

- Log -----------------------------------------------------------------
commit cdd06489088cf64a0e621b79cdf0c48eb55f2622
Author: Ricardo Signes <[email protected]>
Date:   Sat Jan 12 07:12:34 2013 -0500

    expect a different error for `perl dir` on Win32
    
    We've known that this is how Win32 behaves, as it was documented in
    the ticket for which this is a fix.  I don't think it's worth the
    bother of ensuring we get EISDIR, as long as we don't just exit
    silently!

M       t/run/switches.t

commit d76c0f4b7c12ce4b57e1bfabddfa25594ae3f72a
Author: Ricardo Signes <[email protected]>
Date:   Mon Jan 7 15:00:08 2013 -0500

    perldelta for #61362, croak on `perl directory`

M       pod/perldelta.pod

commit 1044e8d233de553cec1c76db4c74a0e5fe4666e4
Author: James E Keenan <[email protected]>
Date:   Sat Jan 5 22:25:29 2013 -0500

    Add a test to detect error when attempting to syntax-check a directory.
    
    For: RT #61362

M       t/run/switches.t

commit 1dfef69b3a0643e5cf8879e1476b0163c3e8a9b2
Author: Ricardo Signes <[email protected]>
Date:   Sat Jan 5 20:30:48 2013 -0500

    croak on an attempt to run a directory as a script
    
    How many times have I meant to run "perl -I lib myprog" but instead
    run "perl lib myprog" only to exit 0 because that's what perl does
    when you try to run a directory as a script (at least on unix)?  Many.
    
    perl should croak when instructed to execute a directory.
    [perl #61362] suggests it already does so on Win32.  Now it does it
    everywhere.  Tests not yet written.

M       perl.c
-----------------------------------------------------------------------

Summary of changes:
 perl.c            |    8 ++++++++
 pod/perldelta.pod |    6 ++++++
 t/run/switches.t  |   17 ++++++++++++++++-
 3 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/perl.c b/perl.c
index c7e1d54..d4f13df 100644
--- a/perl.c
+++ b/perl.c
@@ -3649,6 +3649,7 @@ S_open_script(pTHX_ const char *scriptname, bool 
dosearch, bool *suidscript)
     int fdscript = -1;
     PerlIO *rsfp = NULL;
     dVAR;
+    Stat_t tmpstatbuf;
 
     PERL_ARGS_ASSERT_OPEN_SCRIPT;
 
@@ -3758,6 +3759,13 @@ S_open_script(pTHX_ const char *scriptname, bool 
dosearch, bool *suidscript)
     /* ensure close-on-exec */
     fcntl(PerlIO_fileno(rsfp), F_SETFD, 1);
 #endif
+
+    if (PerlLIO_fstat(PerlIO_fileno(rsfp), &tmpstatbuf) >= 0
+        && S_ISDIR(tmpstatbuf.st_mode))
+        Perl_croak(aTHX_ "Can't open perl script \"%s\": %s\n",
+            CopFILE(PL_curcop),
+            strerror(EISDIR));
+
     return rsfp;
 }
 
diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index 2103843..ea4db73 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -367,6 +367,12 @@ in the OUTPUT: section (which previous did nothing to the 
SV), and a read only
 SV (literal) is passed to the XSUB, croaks like "Modification of a read-only
 value attempted" will happen. [perl #115796]
 
+=item *
+
+On many platforms, providing a directory name as the script name caused perl
+to do nothing and report success.  It should now universally report an error
+and exit nonzero. [perl #61362]
+
 =back
 
 =head1 Known Problems
diff --git a/t/run/switches.t b/t/run/switches.t
index 5c3b5ee..43d01ca 100644
--- a/t/run/switches.t
+++ b/t/run/switches.t
@@ -11,7 +11,7 @@ BEGIN {
 
 BEGIN { require "./test.pl"; }
 
-plan(tests => 114);
+plan(tests => 115);
 
 use Config;
 
@@ -107,6 +107,21 @@ SWTEST
     );
 }
 
+{
+    my $tempdir = tempfile;
+    mkdir $tempdir, 0700 or die "Can't mkdir '$tempdir': $!";
+
+    # Win32 won't let us open the directory, so we never get to die with
+    # EISDIR, which happens after open.
+    my $error = $^O eq 'MSWin32' ? 'Permission denied' : 'Is a directory';
+    like(
+        runperl( switches => [ '-c' ], args  => [ $tempdir ], stderr => 1),
+        qr/Can't open perl script.*$tempdir.*$error/s,
+        "RT \#61362: Cannot syntax-check a directory"
+    );
+    rmdir $tempdir or die "Can't rmdir '$tempdir': $!";
+}
+
 # Tests for -l
 
 $r = runperl(

--
Perl5 Master Repository

Reply via email to