1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Command escaping is both incorrect and unnecessary.

The escaping behavior is incorrect in that it only escapes the first apostrophe, which is only made necessary because commands are execute through `bash`.  Since `bash` is not guaranteed to be installed (sad, but true), and since this represents unexpected behavior, I've pared this down to the simplest thing that could possibly work.
This commit is contained in:
Pieter van de Bruggen 2011-04-02 14:06:20 -07:00
parent d15a72239f
commit bbc03a4da3

View file

@ -51,11 +51,10 @@ module Fog
begin begin
Net::SSH.start(@address, @username, @options) do |ssh| Net::SSH.start(@address, @username, @options) do |ssh|
commands.each do |command| commands.each do |command|
escaped_command = command.sub(/'/, %{'"'"'}) result = Result.new(command)
result = Result.new(escaped_command)
ssh.open_channel do |ssh_channel| ssh.open_channel do |ssh_channel|
ssh_channel.request_pty ssh_channel.request_pty
ssh_channel.exec(%{bash -lc '#{escaped_command}'}) do |channel, success| ssh_channel.exec(command) do |channel, success|
unless success unless success
raise "Could not execute command: #{command.inspect}" raise "Could not execute command: #{command.inspect}"
end end