I would like to execute my javascript programs with the Rhino shell without making the first line #!/bin/sh. ‘#’ isn’t a comment character in javascript. I also don’t want to have to have a .js extension.
Is this possible? I remember reading something a long while about a method of making java programs to run without an explicit interpreter. Google has not been forthcoming, however.
You’ll want to use the kernel-module
binfmt_miscfor this. I don’t have a JS interpreter installed, but I guess the magic would be something like this for Rhino:This assumes that your scripts are happy to be run like:
If you need to pass any arguments to Rhino, then you’ll need to set up a wrapper. Full documentation for
binfmt_miscis here.