Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Technically it doesn't... If you drop

    echo "hello world"
into a file and chmod +x it, it will run with /bin/sh

You technically only need the shebang to set a specific shell, or options.

... This little quirk allows you to commit crimes like:

    //usr/bin/cc -o ${o=$(mktemp)} "$0" && exec -a "$0" "$o" "$@"
    #include <stdio.h>
    int main(void){
        printf("hello world\n");
        return 0;
    }
which will autocompile and run on execution.

(don't)



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: