J
Joseph Pecoraro
In writing a script that takes strings on the command line I have run
into a small problem which I don't see any way around. Here is a very
simplified program that just prints out the first command line argument,
and using p you can see exactly what is in the string.
[example.rb]
<code>p $*[0]</code>
Now when I send some different (but similar) strings I end up with the
same result in the ARGV array:
$ ruby example.rb "\a"
"\\a"
$ ruby example.rb "\\a"
"\\a"
$ ruby example.rb \\\a
"\\a"
1) Is this because I am running in bash and the shell maps the \\ into a
single backslash?
2) Is there any way around this in Ruby or from the command line (in
bash) so that I can differentiate between these?
Thanks,
Joseph Pecoraro
into a small problem which I don't see any way around. Here is a very
simplified program that just prints out the first command line argument,
and using p you can see exactly what is in the string.
[example.rb]
<code>p $*[0]</code>
Now when I send some different (but similar) strings I end up with the
same result in the ARGV array:
$ ruby example.rb "\a"
"\\a"
$ ruby example.rb "\\a"
"\\a"
$ ruby example.rb \\\a
"\\a"
1) Is this because I am running in bash and the shell maps the \\ into a
single backslash?
2) Is there any way around this in Ruby or from the command line (in
bash) so that I can differentiate between these?
Thanks,
Joseph Pecoraro