Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check syntax of ruby script that has script/runner as a shebang?

Tags:

I have problems to check syntax of ruby scripts that has rails script/runner on its shebang.

Here are two example scripts and how they responses to ruby syntax checking:

Script hello_world_runner.rb:

#!/usr/bin/env script/runner
p "Hello world!"

Script hello_world.rb

#!/usr/bin/env ruby
p "Hello world!"

Here is how I try to check the syntax. First line is a command and a second line is an output.

$ ruby -c hello_world_runner.rb 
"Hello world!"

$ ruby -c hello_world.rb 
SYNTAX OK
like image 790
Joni Avatar asked Sep 12 '11 06:09

Joni


2 Answers

You can try this

tail -n +2 hellow_world_runner.rb | ruby -c

Not ideal but should work.

like image 94
mb14 Avatar answered Sep 29 '22 14:09

mb14


The ruby command line has these 2 flags that might assist you, I use:

ruby -wc test.rb
like image 40
Eran Chetzroni Avatar answered Sep 29 '22 16:09

Eran Chetzroni