From: brabuhr@... Date: 2011-02-10T21:22:40+09:00 Subject: Re: System calls with ` in parameters On Wed, Feb 9, 2011 at 6:48 PM, Gerad S. wrote: > Because of this, the syntax of: > > `echo "#{someVar}" | ./some-script.py > "#{outputFile}"` > > is breaking when #{someVar} contains the tick `.  This causes the > command to fail because it executes up to the tick ` in someVar and not > to the end as intended. > > I have also tried using the system() command as follows: > > system("echo \"#{someVar}\" | ./some-script.py > \"#{outputFile}\"") > > But this fails when there is a tick ` in #{someVar} as well. Could you show us a working example of the problem? >> s = "foo `date` baz" => "foo `date` baz" >> system "echo #{s}" foo Thu Feb 10 07:18:23 EST 2011 baz => true >> system "echo \"#{s}\"" foo Thu Feb 10 07:18:32 EST 2011 baz => true >> system "echo '#{s}'" foo `date` baz => true >> require 'shellwords' => true >> `echo #{Shellwords.escape(s)}` => "foo `date` baz\n"