Last active
November 18, 2015 15:58
-
-
Save trevrosen/653282fc5717c2ab5bdd to your computer and use it in GitHub Desktop.
How MRI Ruby's ARGV really works
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The docs say that ARGV[0] should be the name of the Ruby executable. | |
# http://ruby-doc.org/core-2.2.3/Object.html#ARGV | |
# | |
# This is **NOT** how Ruby actually behaves: | |
─trevorrosen@Saramago ~ | |
╰─$ cat argv-test.rb | |
#!/usr/bin/env ruby | |
p ARGV[0] | |
╭─trevorrosen@Saramago ~ | |
╰─$ ruby argv-test.rb | |
nil | |
╭─trevorrosen@Saramago ~ | |
╰─$ ruby argv-test.rb foo | |
"foo" | |
╭─trevorrosen@Saramago ~ | |
╰─$ ./argv-test.rb | |
nil | |
╭─trevorrosen@Saramago ~ | |
╰─$ ./argv-test.rb foo | |
"foo" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment