Skip to content

Commit

Permalink
Merge pull request #254 from dylanahsmith/no-eof-on-sudo
Browse files Browse the repository at this point in the history
Don't default to closing the input stream when sudo is being used.
  • Loading branch information
carsomyr committed Aug 20, 2012
2 parents 3632188 + 51296cb commit d263896
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/capistrano/configuration/actions/invocation.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ def invoke_command(cmd, options={}, &block)
# variable, they will apply for all invocations of #run, #invoke_command, # variable, they will apply for all invocations of #run, #invoke_command,
# and #parallel. # and #parallel.
def run(cmd, options={}, &block) def run(cmd, options={}, &block)
options = options.merge(:eof => !block_given?) if options[:eof].nil? if options[:eof].nil? && !cmd.include?(sudo)
options = options.merge(:eof => !block_given?)
end
block ||= self.class.default_io_proc block ||= self.class.default_io_proc
tree = Command::Tree.new(self) { |t| t.else(cmd, &block) } tree = Command::Tree.new(self) { |t| t.else(cmd, &block) }
run_tree(tree, options) run_tree(tree, options)
Expand Down
5 changes: 5 additions & 0 deletions test/configuration/actions/invocation_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ def test_sudo_should_default_to_sudo
@config.sudo "ls" @config.sudo "ls"
end end


def test_sudo_should_keep_input_stream_open
@config.expects(:execute_on_servers).with(:foo => "bar")
@config.sudo "ls", :foo => "bar"
end

def test_sudo_should_use_sudo_variable_definition def test_sudo_should_use_sudo_variable_definition
@config.expects(:run).with("/opt/local/bin/sudo -p 'sudo password: ' ls", {}) @config.expects(:run).with("/opt/local/bin/sudo -p 'sudo password: ' ls", {})
@config.options[:sudo] = "/opt/local/bin/sudo" @config.options[:sudo] = "/opt/local/bin/sudo"
Expand Down

0 comments on commit d263896

Please sign in to comment.