I’m trying to access the original command line argument string in Ruby (ie – not using the pre-split/separated ARGV array). Does anyone know how to do this? For example:
$> ruby test.rb command "line" arguments
I want to be able to tell if ‘line’ had quotes around it:
"command \"line\" arguments"
Any tips? Thanks in advance
As far as I can tell, ruby is not removing those double-quotes from your command line. The shell is using them to interpolate the contents as a string and pass them along to ruby.
You can get everything that ruby receives like this:
Why do you need to know what is in quotes? Can you use some other delimiter (like ‘:’ or ‘#’)?
If you need to, you can pass double-quotes to ruby by escaping them:
The above
cmd_linevariable would receive the following string in that case: