CountZero's blog

By CountZero, history, 6 months ago, translation, In English,

borrowed from https://gist.github.com/jdarpinian/1952a58b823222627cc1a8b83a7aa4e2

This trick is for linux/mac/wsl. Just add one comment to the top of your source file

C++

run chmod +x test.cpp and that's it, you can use it as an executable:

$ ./test.cpp
hello world

you can do this with java too:

Java

Enjoy!

 
 
 
 
  • Vote: I like it  
  • +76
  • Vote: I do not like it  

»
6 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been translated by CountZero (original revision, translated revision, compare)

»
6 months ago, # |
  Vote: I like it 0 Vote: I do not like it

It looks like langs like c++ supports [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)/) too.

  • »
    »
    6 months ago, # ^ |
      Vote: I like it +8 Vote: I do not like it

    It's not language, it's the Linux kernel itself.