https://stackoverflow.com/revisions/76883115/1#:~:text=%23!/usr/bin/env%20node,ecmascript%20in%20the%20TC39%20meeting explains that ECMAScript supports it. VSCode certainly correctly interprets it as a comment. Consequently, does Firefox?
Firefox does not execute JS files on the command line. It just loads them as text files. So it doesn’t interpret any of the text of the file as anything, including a #! line.
You could certainly make a file with
#!/bin/env firefox
as its first line, make it executable, and it would launch firefox on itself. But again, it’s just going to display that file as text, with no interpretation. (Well, unless you name it something.html, in which case it will interpret the contents as HTML, and the #! will be outside of any tags and therefore treated as body text.
Your question sounds like you’re thinking of some program that executes JS files passed to it on the command line. The Firefox code base does include a JS test shell that does this, and it does interpret the #! line as a comment. But the JS test shell does not ship with Firefox.
@sfink, sometimes a JS file has a Node shebang but shall execute just fine in Firefox. In that case, I merely want to ensure that Firefox shall parse that line correctly, since #
isn’t a comment in JS, and thus would surely trigger a syntax error if not disregarded by the interpreter.
Thanks. I’d not actually considered that use case, but that’s really quite interesting - using JS like any other scripting language.
As in, it’s in moz-central
, but isn’t included in the compiled packages officially distributed?