what is the use of “#!/usr/local/bin/ruby -w” at the start of a ruby program

前端 未结 3 998
野的像风
野的像风 2020-12-24 01:47

what is the use of writing the following command at the start of a ruby program ?

#!/usr/local/bin/ruby -w

Is it OS specific command? Is it

3条回答
  •  滥情空心
    2020-12-24 02:20

    Although the execution behavior of a shebang line does not translate directly to the Windows world, the flags included on that line (for example the -w in your question) do affect the running Ruby script.

    Example 1 on a Windows machine:

    #!/usr/local/bin/ruby -w
    puts $VERBOSE   # true
    

    Example 2 on a Windows machine:

    #!/usr/local/bin/ruby
    puts $VERBOSE   # false
    

提交回复
热议问题