From: Jim Cromie Date: Wed, 21 Jul 2004 11:21:50 +0000 (-0600) Subject: Re: "Too late for -T" could be more descriptive X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fa3aa65a5ab84a4dd986ed927a8fcbf6d6dfcf43;p=p5sagit%2Fp5-mst-13.2.git Re: "Too late for -T" could be more descriptive Message-ID: <40FEA62E.2010809@divsol.com> (with tweaks) p4raw-id: //depot/perl@23150 --- diff --git a/perl.c b/perl.c index 7eb121e..d818f50 100644 --- a/perl.c +++ b/perl.c @@ -3126,9 +3126,8 @@ S_open_script(pTHX_ char *scriptname, bool dosearch, SV *sv) #endif /* IAMSUID */ if (!PL_rsfp) { /* PSz 16 Sep 03 Keep neat error message */ - Perl_croak(aTHX_ "Can't open perl script \"%s\": %s%s\n", - CopFILE(PL_curcop), Strerror(errno), - ".\nUse -S to search $PATH for it."); + Perl_croak(aTHX_ "Can't open perl script \"%s\": %s\n", + CopFILE(PL_curcop), Strerror(errno)); } } diff --git a/perl.h b/perl.h index 9303419..99449e7 100644 --- a/perl.h +++ b/perl.h @@ -751,7 +751,7 @@ int usleep(unsigned int); # define MALLOC_CHECK_TAINT(argc,argv,env) #endif /* MYMALLOC */ -#define TOO_LATE_FOR_(ch,s) Perl_croak(aTHX_ "Too late for \"-%c\" option%s", (char)(ch), s) +#define TOO_LATE_FOR_(ch,s) Perl_croak(aTHX_ "\"-%c\" is on the #! line, it must also be used on the command line", (char)(ch), s) #define TOO_LATE_FOR(ch) TOO_LATE_FOR_(ch, "") #define MALLOC_TOO_LATE_FOR(ch) TOO_LATE_FOR_(ch, " with $ENV{PERL_MALLOC_OPT}") #define MALLOC_CHECK_TAINT2(argc,argv) MALLOC_CHECK_TAINT(argc,argv,NULL) diff --git a/pod/perldebug.pod b/pod/perldebug.pod index e44eaaf..6934652 100644 --- a/pod/perldebug.pod +++ b/pod/perldebug.pod @@ -1014,6 +1014,12 @@ L, and L. +When debugging a script that uses #! and is thus normally found in +$PATH, the -S option causes perl to search $PATH for it, so you don't +have to type the path or `which $scriptname`. + + $ perl -Sd foo.pl + =head1 BUGS You cannot get stack frame information or in any fashion debug functions diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 2df7724..999f289 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -934,6 +934,10 @@ for stdout. (F) The script you specified can't be opened for the indicated reason. +If you're debugging a script that uses #!, and normally relies on the +shell's $PATH search, the -S option causes perl to do that search, so +you don't have to type the path or C<`which $scriptname`>. + =item Can't read CRTL environ (S) A warning peculiar to VMS. Perl tried to read an element of %ENV @@ -3690,6 +3694,22 @@ before now. Check your control flow. (F) Perl can't peek at the stdio buffer of filehandles when it doesn't know about your kind of stdio. You'll have to use a filename instead. +=item "-T" is on the #! line, it must also be used on the command line + +(X) The #! line (or local equivalent) in a Perl script contains the +B<-T> option, but Perl was not invoked with B<-T> in its command line. +This is an error because, by the time Perl discovers a B<-T> in a +script, it's too late to properly taint everything from the environment. +So Perl gives up. + +If the Perl script is being executed as a command using the #! +mechanism (or its local equivalent), this error can usually be fixed by +editing the #! line so that the B<-T> option is a part of Perl's first +argument: e.g. change C to C. + +If the Perl script is being executed as C, then the +B<-T> option must appear on the command line: C. + =item Target of goto is too deeply nested (F) You tried to use C to reach a label that was too deeply nested @@ -3783,22 +3803,6 @@ system call to call, silly dilly. B<-M> or B<-m> option. This is an error because B<-M> and B<-m> options are not intended for use inside scripts. Use the C pragma instead. -=item Too late for "B<-T>" option - -(X) The #! line (or local equivalent) in a Perl script contains the -B<-T> option, but Perl was not invoked with B<-T> in its command line. -This is an error because, by the time Perl discovers a B<-T> in a -script, it's too late to properly taint everything from the environment. -So Perl gives up. - -If the Perl script is being executed as a command using the #! -mechanism (or its local equivalent), this error can usually be fixed by -editing the #! line so that the B<-T> option is a part of Perl's first -argument: e.g. change C to C. - -If the Perl script is being executed as C, then the -B<-T> option must appear on the command line: C. - =item Too late to run %s block (W void) A CHECK or INIT block is being defined during run time proper, diff --git a/pod/perlrun.pod b/pod/perlrun.pod index d40abb8..e730530 100644 --- a/pod/perlrun.pod +++ b/pod/perlrun.pod @@ -733,9 +733,12 @@ original name fails, and if the name does not already end in one of those suffixes. If your Perl was compiled with DEBUGGING turned on, using the -Dp switch to Perl shows how the search progresses. -Typically this is used to emulate #! startup on platforms that -don't support #!. This example works on many platforms that -have a shell compatible with Bourne shell: +Typically this is used to emulate #! startup on platforms that don't +support #!. Its also convenient when debugging a script that uses #!, +and is thus normally found by the shell's $PATH search mechanism. + +This example works on many platforms that have a shell compatible with +Bourne shell: #!/usr/bin/perl eval 'exec /usr/bin/perl -wS $0 ${1+"$@"}'