29 janeiro 2014

Shebang: How the System Knows a File Is a Ruby Script

Compiled programs have the information about how the operating system should start the program in the executable file. In scripting languages like ruby, python.. the operating system needs another way to know how to start the script. On Unix systems, this is done in the first line of code, known as Shebang.

The shebang begins with #, followed by ! and the absolute path of the interpreter which will execute the script:
#!/usr/bin/ruby
puts "Hello World!"