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

Similarly, make go source executable : https://unix.stackexchange.com/questions/162531/shebang-star...

also, my contribution, make C programs executable:

    $ cat cute-use-of-slash-slash.c
    //usr/bin/env sh -c 'p=$(expr '"_$0"' : "_\(.*\)\.[^.]*"); make $p > /dev/null && $p'; exit

    #include <stdio.h>

    int main()
    {
        puts("hello world");
    }
    $ chmod  +x cute-use-of-slash-slash.c
    $ ./cute-use-of-slash-slash.c
    hello world
    $ $(pwd)/cute-use-of-slash-slash.c
    hello world
    $ ../cc/cute-use-of-slash-slash.c
    hello world
    $ sed -i -e s/hello/bye/ cute-use-of-slash-slash.c
    $ ./cute-use-of-slash-slash.c
    bye world
    $


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

Search: