shebang headers
Abstract
I propose the shebang header as a general-purpose workaround to limitations of the shebang feature. I hope that IDEs will support this proposal. For example, in an IDE such as IntelliJ IDEA the editor would recognize and fold a shebang header in a Java source file and when compiling the file would temporarily replace the header with blank lines.
The shebang feature lets you annotate program source code with enough information so that the program source code can be executed by the system via an "interpreter" for the language of the program.
Unfortunately, the shebang feature is hampered by two problems:
#!
command has to get all of its initialization information from its command line arguments. In some cases it would be more convenient to specify this information in a little language that can occupy multiple lines with optional comments.
This proposal offers a way to workaround these problems that might hope to be a recognized convention.
On 2010-11-06, the first example of shebang header use appeared in the wild, a "Hello world" script using compileAndGo:
#!/usr/bin/env compileAndGo language = java !# public class jello { public static void main(String[] args) { System.out.println("Hello, folks of World!"); } } |
The header comprises the text from the first line of the file
(the #!
line,
also known as the
shebang line)
through the first line that contains only !#
.
The command invoked by the #!
uses the text between #! and !# for its own purposes,
then typically sends the entire file
(after replacing the header lines
with an equal number of blank lines or comment lines)
to some other command,
such as to the javac
compiler in the example above.