SPUG:-s option doesn't always work!

SPUG-list-owner tim at consultix-inc.com
Wed Jun 4 00:13:53 CDT 2003


On Tue, Jun 03, 2003 at 11:58:28PM -0500, Jeff Almeida wrote:
> Also Sprach Tim Maher:
> >
> >I don't use the -s invocation option very often, but for certain
> >categories of students, I think it works well.  So imagine my surprise
> >when I learned today that -s on the shebang line seems to be ignored
> >when the script is invoked as an argument to the perl command!
> >None of the other invocation options I can think of works like that,
> >except -T, and there are good reasons for that -- but not for this,
> >AFAIK.
> 
> IIRC, if you pass the script as an argument to perl, the perl interpreter 
> is going to see the shebang line as a comment -- remember, the shebang 
> isn't for perl's benefit, it's to tell the shell what interpreter to 
> invoke in order to run a particular piece of code, and you've already 
> told the shell that in an explicit manner.  I'm quite surprised 
> that any command line switches work from the shebang line when the script 
> is called as an argument -- obviously there is an explicit hack in the 
> interpreter to look for those... this leads me to be curious if you get 

Hi Jeff, haven't seen you since my Perl Mongers talk in Dallas
some months back, when I advised you not to move to Seattle,
due to the severe economic malaise here (more on this below).

Funny as it may seem, shebang line switches are supposed
to work, documented to work, and the other ones do work, in
this way.  That's because The Larry considers it proper to
harvest the invocation options from the shebang line, so if
you're invoking the script as perl's argument, or launching a
script on a Windows box by clicking an icon, the interpreter
can figure out how it's supposed to behave.

As it is written in "man perlrun",

       The #! line is always examined for switches as the line is
       being parsed.  Thus, if you're on a machine that allows
       only one argument with the #! line, or worse, doesn't even
       recognize the #! line, you still can get consistent switch
       behavior regardless of how Perl was invoked, even if -x
       was used to find the beginning of the program.

> different behavior among different shells (tcsh v. ksh v. bash for 
> instance).  I'll be quite interested to read what others have to say on 
> this.
> 
> New question: it sounds like over the past several months, Portland has 
> made itself into quite the perl mecca (good place to point camels, I 
> suppose *grin*) with Schwern, Ingy, chromatic, et al moving there.  What's 
> going on down there that's causing all the activity?  Needless to say, 
> with my present (lack of a) job situation, moving has certainly moved up 
> in the list of things we could consider :)
>  jeff
> Jeff D. "Spud (Zeppelin)" Almeida

It can't be the economic situation that's drawing them, because Portland
is right up there with Seattle in the top 3 nationwide for having the
highest unemployment.  And most of those folks aren't working too much
these days, from what I've heard.

By the way, Chris Nandor (pudge, of use.perl.org and Perl on Mac OSx fame),
is moving to Washington soon, so we'll have one more guy on our team
shortly!  I've already talked to him about making a SPUGly presentation,
which will be months off, but still something to look forward to.


-Tim
*------------------------------------------------------------*
| Tim Maher (206) 781-UNIX  (866) DOC-PERL  (866) DOC-UNIX   |
| CEO, JAWCAR ("Just Another White Camel Award Recipient")   |
| tim(AT)Consultix-Inc.Com  TeachMeUnix.Com  TeachMePerl.Com |
*+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-*
|  Watch for my Book: "Minimal Perl for Shell Programmers"   |
*------------------------------------------------------------*



More information about the spug-list mailing list