New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Repeated spaces on shebang line stops option parsing #7416
Comments
From tim@consultix-inc.comCreated by tim@consultix-inc.comI've either found a bug in Perl, or there's an undocumented In short, a parsing rule (or bug) seems to be operating that says AFAIK, this is not documented behavior, and IMHO, it is not I've included sample programs and output below, and confirmed that -Tim Maher PROGRAMS: The _sw ending on a test program means the -s option is first, The two_space* versions of the programs are expected to work like 2004-07-05 12:31 one_space_sw Page 1 #! /usr/bin/perl -s -w 2004-07-05 12:31 one_space_ws Page 1 #! /usr/bin/perl -w -s 2004-07-05 12:32 two_spaces_sw Page 1 #! /usr/bin/perl -s -w 2004-07-05 12:32 two_spaces_ws Page 1 #! /usr/bin/perl -w -s OUTPUT: RUNNING 'one_space_sw': (That's the correct result; warnings enabled, and switch-argument processed) RUNNING 'one_space_ws': (That's the correct result; warnings enabled, and switch-argument processed) RUNNING 'two_spaces_sw': (That's the WRONG result; warnings DISabled; RUNNING 'two_spaces_ws': (That's the WRONG result; switch not processed; ==============================================================
|
From renee.baecker@smart-websolutions.deMake perl recognize additional switches when more than one space is used... -- renee.baecker@smart-websolutions.de Perl-Magazin: http://foo-magazin.de |
From renee.baecker@smart-websolutions.deperl.c.patch--- perl.c.old 2008-08-25 10:35:38.000000000 +0200
+++ perl.c 2008-08-25 10:26:22.000000000 +0200
@@ -3370,8 +3370,10 @@
return s;
case '*':
case ' ':
- if (s[1] == '-') /* Additional switches on #! line. */
- return s+2;
+ while( *s && isSPACE(*s) )
+ ++s;
+ if (s[0] == '-') /* Additional switches on #! line. */
+ return s+1;
break;
case '-':
case 0:
|
The RT System itself - Status changed from 'new' to 'open' |
From @nwc10On Mon, Aug 25, 2008 at 10:47:31AM +0200, Rene Bcker wrote:
Do you have an example of what this is solving? It seems a logical change to
That can be while( isSPACE(*s) ) because isSPACE('\0') is going to be false. But is using isSPACE() correct, given that '\r', '\n' and particularly '\t' Nicholas Clark |
From renee.baecker@smart-websolutions.deNicholas Clark wrote:
Attached is a small script. Without this patch it just recognizes the -s
So this should be rewritten as while( *s && ( s[0] == ' ' ) )
Renee |
From @TuxOn Tue, 26 Aug 2008 08:43:55 +0200, Renée Bäcker
That is just one test too many, as it is effectively the same as while (*s == ' ') s++; if *s == (char)0, *s == ' ' will be false while (*s == ' ' || *s == '\t') s++; -- |
From @nwc10On Tue, Aug 26, 2008 at 09:16:16AM +0200, H.Merijn Brand wrote:
Thanks. I used a variant in my test.
Tabs are handled differently in the code below case '\n': so it didn't seem logical to include them here. I applied the appended change. Nicholas Clark Change 34234 by nicholas@nicholas-saigo on 2008/08/28 13:11:44 Fix #30660: Repeated spaces on shebang line stops option parsing Affected files ... ... //depot/perl/perl.c#874 edit Differences ... ==== //depot/perl/perl.c#874 (text) ==== @@ -3431,8 +3431,10 @@ ==== //depot/perl/t/run/switches.t#28 (text) ==== @@ -11,7 +11,7 @@ BEGIN { require "./test.pl"; } -plan(tests => 69); use Config; @@ -350,3 +350,19 @@ |
module@renee-baecker.de - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#30660 (status was 'resolved')
Searchable as RT30660$
The text was updated successfully, but these errors were encountered: