From: Matthew Kerwin Date: 2013-02-22T18:36:28+09:00 Subject: Re: backslash substitution Mario Ruiz wrote in post #1098396: > The problem is I cannot put single or doubles since the value is given > as an argument in command line so the value is taken something like > this: > > ARGV.each do |x| > if !x["folder="].nil? then a=x.gsub("folder=","") end > end Aha! Now some of what you've said starts to make sense. I just created this file: #test.rb: a=nil ARGV.each do |x| if !x["folder="].nil? then a=x.gsub("folder=","") end end p a When I run it in Windows, I get this: > ruby test.rb nil > ruby test.rb folder=a\b\c "a\\b\\c" So you can see that the Windows command prompt has interpreted the single backslashes as backslashes, and passed them through to Ruby faithfully. If I run it in Linux I get this: $ ruby test.rb nil $ ruby test.rb folder=a\b\c "abc" $ ruby test.rb folder=a\\b\\c "a\\b\\c" So you can see that bash (the command prompt I use) has interpreted the backslashes as special characters, not entirely unlike the way ruby would. However bash (and most *nix shells) give you options like this: $ ruby test.rb folder="a\b\c" "a\\b\\c" $ ruby test.rb folder='a\b\c' "a\\b\\c" The gsub line in Ruby would work just fine, but you also have to tell your _command prompt_ what you mean when you write a backslash. -- Posted via http://www.ruby-forum.com/.