From bbc03a4da39db247515eee210a8a204000aff728 Mon Sep 17 00:00:00 2001 From: Pieter van de Bruggen Date: Sat, 2 Apr 2011 14:06:20 -0700 Subject: [PATCH] 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. --- lib/fog/core/ssh.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/fog/core/ssh.rb b/lib/fog/core/ssh.rb index af8b11b56..93ab9bf72 100644 --- a/lib/fog/core/ssh.rb +++ b/lib/fog/core/ssh.rb @@ -51,11 +51,10 @@ module Fog begin Net::SSH.start(@address, @username, @options) do |ssh| commands.each do |command| - escaped_command = command.sub(/'/, %{'"'"'}) - result = Result.new(escaped_command) + result = Result.new(command) ssh.open_channel do |ssh_channel| ssh_channel.request_pty - ssh_channel.exec(%{bash -lc '#{escaped_command}'}) do |channel, success| + ssh_channel.exec(command) do |channel, success| unless success raise "Could not execute command: #{command.inspect}" end