[Omake] "#!" processing.

Jason Hickey jyh at cs.caltech.edu
Fri Apr 27 16:42:23 PDT 2007


On Apr 27, 2007, at 3:44 PM, Aleksey Nogin wrote:

> Note that the original intent from your commit message:
>
>    Another point is that the options are processed at parse time,
>    so options like -warn-error are handled correctly.
>
> does not seem to be implemented (yet?), so is there any reason to  
> process "#!", where the usual OMakeFlags will work the same, but be  
> more predictable?

It appears in var3, but actually I plan to pull it back all the way  
to the keyword branch (because the foreach binder is a compile-time  
warning).

It seems to me that the option parsing is not overly unpredictable.   
For forward compatibility, we need to do the same with a relaxed  
OMakeFlags, at least for warning options.

Mechanically speaking, we must have a syntactic way of specifying  
compile-time flags.  We could use a command (a "keyword") instead.

    # A sh-style "set" command, but also handled at compile time.
    set -Wdeclare -warn-error

Of course, this would almost always occur immediately after the #!  
anyway.  The following kind of code would be a little weird, because  
it means errors-are-warnings only if you execute the script directly  
(not as "osh script").  The advantage of the #! parsing is that it is  
more predictable, because the file is processed the same way no  
matter how you execute it ("./script" is the same as "osh ./script").

    #!osh -warn-error
    set -Wdeclare -Wfoo "PATH=/bin"

Note that in the ignore-#! case, you can't even program consistent  
behavior, because the options have to be processed at compile-time.

    #!osh -warn-error
    # The following does not work, because $* is run-time only
    set $*

Another nice thing about #! is that the programmer doesn't have to  
learn anything new.

Jason

--
Jason Hickey                  http://www.cs.caltech.edu/~jyh
Caltech Computer Science      Tel: 626-395-6568 FAX: 626-792-4257





More information about the OMake-Devel mailing list