Permalink
Browse files

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.

#251
  • Loading branch information...
1 parent 30a942c commit 78e5e9b07266e2b605fba7782ebd797ddc498a00 Ken Stailey committed Aug 27, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 lib/capistrano/shell.rb
View
@@ -171,7 +171,7 @@ def exec_tasks(list)
# 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({})

0 comments on commit 78e5e9b

Please sign in to comment.