logoalt Hacker News

petercooperlast Tuesday at 3:00 PM0 repliesview on HN

Cute trick! I pointlessly wondered if I could make it work with Ruby and you kinda can, if you can tolerate a single error message before the script runs (sadly # comments don't work as shells consider them comments too):

    =begin
    ruby $0; exit
    =end

    puts "Hello from Ruby"
Not immediately useful, but no doubt this trick will pop up at some random moment in the future and actually be useful. Very basic C99 too, though I'm not sure I'd want to script with it(!):

    //usr/bin/cc $0 && ./a.out && exit