Skip to content

Instantly share code, notes, and snippets.

What would you like to do?

Various command line applications use an Interpreter Directive to define how they should be run.

#! js -m foo
#! node foo
#! eshost foo

I propose we add this as a top level syntax to ECMA262 as a comment that can occur before a DirectivePrologue.

Early Errors





Module := HashBang (opt) ...
Script := HashBang (opt) ...
HashBang := "#!" SingleLineCommentChars (opt)

DirectivePrologue Change

DirectivePrologue text should be changed to explicitly allow HashBang to occur in front of it.

Stage 1?


This comment has been minimized.

Copy link

@michaelficarra michaelficarra commented Nov 10, 2017

@bmeck I would call this Shebang instead of InterpreterDirective (to avoid the word "directive") and it should just be the first non-terminal in Script and Module. Something like

Shebang :: #! SingleLineCommentChars(opt)
Script : Shebang(opt) ScriptBody(opt)
Module : Shebang(opt) ModuleBody(opt)

This comment has been minimized.

Copy link

@michaelficarra michaelficarra commented Nov 11, 2017

@bmeck Directive prologues are unrelated to this proposal. You should remove the mention. Remember, directive prologues may be present in function bodies, a location where we definitely don't want to allow shebangs.


This comment has been minimized.

Copy link
Owner Author

@bmeck bmeck commented Nov 13, 2017

@michaelficarra DirectivePrologue is affected by the initial statement list, we need to be sure that HashBang doesn't prevent the DirectivePrologue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment