Magic Number
The shebang is actually a human-readable instance of a magic number in the executable file, the magic byte string being 0x23 0x21, the two-character encoding in ASCII. This magic number is detected by the "exec" family of functions, which determine whether an image file is a script or an executable binary. The presence of the shebang will result in the execution of the specified executable, usually an interpreter for the script's language. It has been claimed that some old versions of Unix expect the normal shebang to be followed by a space and a slash ("#! /"), but this appears to be untrue.
The shebang characters are represented by the same two bytes in extended ASCII encodings, including UTF-8, which is commonly used for scripts and other text files on current Unix-like systems. However, UTF-8 files may begin with the optional byte order mark (BOM); if the "exec" function specifically detects the bytes 0x23 0x21, then the presence of the BOM (0xEF 0xBB 0xBF) before the shebang will prevent the script interpreter from being executed. Some authorities recommend against using the byte order mark in POSIX (Unix-like) scripts, for this reason and for wider interoperability and philosophical concerns. Additionally, a byte order mark is not necessary in UTF-8, as that encoding does not have endianness issues; it serves only to identify the encoding as UTF-8.
Read more about this topic: Shebang (Unix), Portability
Famous quotes containing the words magic and/or number:
“The middle years of parenthood are characterized by ambiguity. Our kids are no longer helpless, but neither are they independent. We are still active parents but we have more time now to concentrate on our personal needs. Our childrens world has expanded. It is not enclosed within a kind of magic dotted line drawn by us. Although we are still the most important adults in their lives, we are no longer the only significant adults.”
—Ruth Davidson Bell. Ourselves and Our Children, by Boston Womens Health Book Collective, ch. 3 (1978)
“In the multitude of middle-aged men who go about their vocations in a daily course determined for them much in the same way as the tie of their cravats, there is always a good number who once meant to shape their own deeds and alter the world a little.”
—George Eliot [Mary Ann (or Marian)