开发者

Escaping # in cmd line argument

开发者 https://www.devze.com 2023-01-07 00:35 出处:网络
I have a simple Ruby program which takes the command line arguments and posts them to a server. However, I want to be able to write the # (pound, hash symbol) in my arguments wit开发者_运维知识库hout

I have a simple Ruby program which takes the command line arguments and posts them to a server.

However, I want to be able to write the # (pound, hash symbol) in my arguments wit开发者_运维知识库hout ruby trying to parse it. I'm not so familiar with Ruby. I know I can pass the arg with quotes, but I would like to know if it's possible without them.

ARGV.each do |a|
    s = '' + a
    puts "Argument: #{s}"
end

The above doesn't work. Maybe something with gsub?


Just like this

puts "Argument: ##{s}"

#is special in " " only when it meets {}. Otherwise, it shows #.

0

精彩评论

暂无评论...
验证码 换一张
取 消