List of Shebang Interpreter Directives

This topic was published by and viewed 2462 times since "". The last page revision was "".

Viewing 1 post (of 1 total)
  • Author
    Posts

  • DevynCJohnson
    Keymaster
    • Topics - 437
    • @devyncjohnson

    The hashpling is the first line of a script, and it begins with "#!". When a script is executed, the program-loader will read the first line and see the hashpling. Then, the program-loader will pass the script to the specified interpreter in the hashpling. Once the interpreter receives the script, the script will be read and executed. The interpreter itself views the hashpling as it would any other comment. The hashpling only has importance to the program-loader or any software that checks magic numbers. The Magic Number for hashplings is "0x23 0x21" which is the ASCII characters "#!" in hexadecimal form.

    Some scripting languages have more than one possible hashpling. The variations is due to multiple factors such as

    • the script interpreters being in different locations
    • the use of the portable "#!/usr/bin/env" hashpling
    • parameters in the hashpling

    FUN FACT: #!path arg translates to the syscall execve("path", ["path", "arg"], env);. #!/usr/bin/env ARG is a portable hashpling.

    Below is a list of hashplings recognized and used by various scripting languages and interpreters. The list may not be complete, and some of th listed hashplings may not work on some Unixoid systems.

    NOTE: Any text after a "#//" is a comment of mine to explain the hashpling.

    • ASH - #!/bin/ash
    • awk - #!/usr/bin/awk -f
    • BASH -
      • #!/bin/bash
      • #!/usr/bin/env bash
    • Busybox - #!/bin/busybox sh
    • csh -
      • #!/bin/csh
      • #!/bin/csh -f
    • Groovy -
      • #!/usr/local/bin/groovy
      • #!/usr/bin/env groovy
    • JavaScript -
      • #!/usr/bin/env jsc
      • #!/usr/bin/env node
      • #!/usr/bin/env rhino
    • Lisp - #!/usr/local/bin/sbcl --script #//Steel Bank Common Lisp
    • Lua -
      • #!/usr/bin/env lua
      • #!/usr/bin/lua
    • make - #!/usr/bin/make -f
    • Perl -
      • #!/usr/bin/env perl
      • #!/usr/bin/perl
      • #!/usr/bin/perl -T #//taint checks
    • PHP -
      • #!/usr/bin/php
      • #!/usr/bin/env php
    • Python - #!/usr/bin/env python
    • Python3 - #!/usr/bin/env python3
    • Python3.4 - #!/usr/bin/env python3.4
    • Ruby -
      • #!/usr/bin/env ruby
      • #!/usr/bin/ruby
    • sed -
      • #!/bin/sed -f
      • #!/usr/bin/sed -f
      • #!/usr/bin/env sed
    • Shell (POSIX Shell) - #!/bin/sh
    • Solaris POSIX Shell - #!/usr/xpg4/bin/sh
    • Tcsh - #!/bin/tcsh

    FUN FACT: OpenServer and Unicos are two examples of systems that store "env" under /bin/ rather than the usual /usr/bin/. On such systems, the admins should create a soft-link, or the program's installation script should create one.

    Further Reading

Viewing 1 post (of 1 total)