Permalink
Browse files

Don't default to closing the input stream when sudo is being used.

Fixes #253
  • Loading branch information...
1 parent 62a6cb7 commit 51296cbc7dec55a6e70992e9a8ae5b51b0902252 @dylanahsmith dylanahsmith committed Aug 18, 2012
@@ -147,7 +147,9 @@ def invoke_command(cmd, options={}, &block)
# variable, they will apply for all invocations of #run, #invoke_command,
# and #parallel.
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
tree = Command::Tree.new(self) { |t| t.else(cmd, &block) }
run_tree(tree, options)
@@ -115,6 +115,11 @@ def test_sudo_should_default_to_sudo
@config.sudo "ls"
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
@config.expects(:run).with("/opt/local/bin/sudo -p 'sudo password: ' ls", {})
@config.options[:sudo] = "/opt/local/bin/sudo"

0 comments on commit 51296cb

Please sign in to comment.