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.
int fdscript = -1;
PerlIO *rsfp = NULL;
dVAR;
+ Stat_t tmpstatbuf;
PERL_ARGS_ASSERT_OPEN_SCRIPT;
/* 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;
}