From 78e5e9b07266e2b605fba7782ebd797ddc498a00 Mon Sep 17 00:00:00 2001 From: Ken Stailey Date: Mon, 27 Aug 2012 19:15:30 -0400 Subject: [PATCH] Can't use sudo as an argument in cap shell command Leave sudo alone when it is in a position that a command argument uses. https://github.com/capistrano/capistrano/issues/251 --- lib/capistrano/shell.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/capistrano/shell.rb b/lib/capistrano/shell.rb index 5f843a74..5384d1c5 100644 --- a/lib/capistrano/shell.rb +++ b/lib/capistrano/shell.rb @@ -171,7 +171,7 @@ HELP # Execute a command on the given list of servers. def exec_command(command, servers) - command = command.gsub(/\bsudo\b/, "sudo -p '#{configuration.sudo_prompt}'") + command = command.gsub(/^(\s*)sudo\b|([|;&])\s*sudo\b/, "\\0 -p '#{configuration.sudo_prompt}'") processor = configuration.sudo_behavior_callback(Configuration.default_io_proc) sessions = servers.map { |server| configuration.sessions[server] } options = configuration.add_default_command_options({})