开发者

Escaping # in cmd line argument

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜