Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Don't emit -p for sudo when :sudo_prompt is blank

  • Loading branch information...
commit 21325e29c4e86a4e60e29839c4c7828fa797824b 1 parent 76a948f
@jamis jamis authored
View
4 CHANGELOG.rdoc
@@ -1,7 +1,9 @@
== (unreleased)
+* Don't emit -p for sudo when :sudo_prompt is blank [Matthias Marschall]
+
* Copy symlinks when using rsync [Paul Paradise]
-*
+
* Make sure git query-revision matches on exact branch name [grant@nightriot.com]
* Use -T <arg> to filter listed tasks by namespace [Mathias Meyer]
View
3  lib/capistrano/configuration/actions/invocation.rb
@@ -103,7 +103,8 @@ def sudo(*parameters, &block)
command = parameters.first
user = options[:as] && "-u #{options.delete(:as)}"
- sudo_command = [fetch(:sudo, "sudo"), "-p '#{sudo_prompt}'", user].compact.join(" ")
+ sudo_prompt_option = "-p '#{sudo_prompt}'" unless sudo_prompt.empty?
+ sudo_command = [fetch(:sudo, "sudo"), sudo_prompt_option, user].compact.join(" ")
if command
command = sudo_command + " " + command
View
6 test/configuration/actions/invocation_test.rb
@@ -114,6 +114,12 @@ def test_sudo_should_pass_options_through_to_run
@config.sudo "ls", :foo => "bar"
end
+ def test_sudo_should_avoid_minus_p_when_sudo_prompt_is_empty
+ @config.set :sudo_prompt, ""
+ @config.expects(:run).with("sudo ls", {})
+ @config.sudo "ls"
+ end
+
def test_sudo_should_interpret_sudo_prompt_variable_as_custom_prompt
@config.set :sudo_prompt, "give it to me: "
@config.expects(:run).with("sudo -p 'give it to me: ' ls", {})

0 comments on commit 21325e2

Please sign in to comment.
Something went wrong with that request. Please try again.