yorkie / proposal-hashbang

#! for JS

Home Page:https://tc39.github.io/proposal-hashbang/out.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hashbang Grammar

This proposal is to match de-facto usage in some CLI JS hosts that allow for Shebangs / Hashbang. Such hosts strip the hashbang in order to generate valid JS source texts before passing to JS engines currently. This would unify and standardize how that is done.

Example

#!/usr/bin/env node
// in the Script Goal
'use strict';
console.log(1);
#!/usr/bin/env node
// in the Module Goal
export {};
console.log(1);

Status

  • Stage: 3
  • Tests
  • Spec PR: TODO
  • Implementations shipping:
    • Chrome Canary 74
    • Firefox Nightly 67

Why Hashbang instead of Shebang

Hash is commonly associated with modern terms involving # such as hashtag. In addition for discoverability, the term "hash sign" is used for # but "she sign" is not.

Why only at the start of a Source Text

Hashbang directives are only valid at the start of a file for interpretters in various CLI environments. There is no gain for the intended usage by allowing it in other places and in fact could lead to confusion since it would not be picked up by CLI environments. Additionally by allowing Hashbang in other places it overlaps a grammar space for #! if it is an inifix binary expression of some kind. Use // if you want line comments elsewhere.

Existing Notes from Meetings

About

#! for JS

https://tc39.github.io/proposal-hashbang/out.html


Languages

Language:HTML 100.0%