
|
HASHBANG
|
 |
HashBang
A hashbang is a mechanism that
allows a shell script to be treated as an executable file by making the
first two bytes appear as a magic number, represented by the "#!"
ASCII characters. The first line of a script that utilizes the hashbang
mechanism contains the the hashbang followed by the path of the script
interpreter. For example:
#!/bin/sh (For the Bourne Shell)
#!/bin/awk (For the awk interpreter)
#!/bin/bash (For the Bourne Again Shell)
#!/bin/csh (For the C Shell)
#!/bin/tcl (For the tcl interpreter)
#!/bin/perl (For the perl interpreter)
#!/bin/wish (For the Windowing Shell)
#!/bin/yabasic (For the yabasic interpreter)
Magic
Numbers
Under Unix, if the first two bytes of an executable file are "#!",
the
kernel treats the file as a script rather than binary code. The
hashbang is a human readable instance of the magic number 0x2321 at
the beginning of the executable file, and allows a script to be
invoked as a command from any type of shell.
Command
Line Arguments
The "Hashbang" line is the first line of the script, which contains
the hashbang followed by the path of the script interpreter.
It is possible to specify command line arguments on the hashbang line.
This feature allows invocation flags to be set for the shell
interpreter.
Comments
All comments in shell scripts start with a hash sign. This enables a
hashbang to be ignored as a comment, if the script is invoked
indirectly, rather than through the hashbang mechanism.
The hashbang annoyance