Twitter Updates

Friday, 22 August 2008

Shebang Line Magic

For scripts that are written in languages that often have a nonstandard install location I use to just call directly eg $ruby script.rb. as there was non standard dir like #!/bin/bash

but I recently discovered a nice shebang line trick.
#!/usr/bin/env ruby
Will look up the users path to the program and call it. So as long as ruby is intstalled and on the users path (as it would need to be for ruby script.rb to work) the script should be portable between users/systems. Now I just call $script.rb

No comments: