thorny script argument escaping problem
Lars Kellogg-Stedman
lars at larsshack.org
Wed Jun 21 16:02:56 EDT 2006
> That would be nice BUT I would need to dynamically create a list of
> arguments for the system method. If I pass in a string (a
> comma-separated list of quoted arguments), the system() method treats
> that as ONE argument.
Yes, and I am suggesting that instead of passing a string you pass it a
list. I don't know any ruby, but in python or perl you'd do this by
appending elements to your list until you have what you want.
After spending a few minutes looking at the ruby docs, it looks like you
could:
cmd = [ '/my/command' ]
cmd.push('an argument with spaces')
cmd.push('"an argument with spaces and quotation marks"')
cmd.push('an argument with <weird shell metacharacters>')
Kernel.system(*cmd)
-- Lars
More information about the Discuss
mailing list