From: Mark Wilson Date: 2003-09-01T09:17:25+09:00 Subject: Re: `echo %!(*` On Sunday, August 31, 2003, at 07:46 PM, Tom Felker wrote: > oldName = "02_Ship_At_Sea_(Instrumental).ogg" > tags = Hash.new > `vorbiscomment #{oldName}`.each_line do |line| > key, value = line.split("=", 2) > tags[key.downcase] = value > end > # ...use tags to formulate proper filename and rename > > # Errors: > sh: -c: line 1: syntax error near unexpected token `(' > sh: -c: line 1: `vorbiscomment 02_Ship_At_Sea_(Instrumental).ogg' > .... > > If you use system, you can pass the arguments in an array, and the > shell > isn't used, so you can have arguments that the shell would barf on. > > system("echo !@#$%^&") == "" > system("echo", "!@#$%^&") == "!@#$%^&") > > I need a backtick method that works the same way. Having popen work > that way would be nice. As it is, I think it's only possible with > popen("-"), having the child exec in such a way as to not interpolate > the arguments, and reading from that. > [snip] Your error is a shell syntax error, and not a Ruby error. Unix shells don't recognize unescaped parentheses within file names. Change the line oldName = "02_Ship_At_Sea_(Instrumental).ogg" to oldName = "02_Ship_At_Sea_\(Instrumental\).ogg"