diff options
author | Akshay Karle <akshay.a.karle@gmail.com> | 2013-09-26 15:06:27 +0530 |
---|---|---|
committer | Akshay Karle <akshay.a.karle@gmail.com> | 2013-09-26 23:10:39 +0530 |
commit | c0173e6b26dff8e8f99a779412eafccb1d2165d0 (patch) | |
tree | fbdf85bd08b6c0c5fb83a6789b7f1c9018bafef0 | |
parent | e986fc3ea9d0a6f09c005e7240db60b4db2861a7 (diff) | |
download | mixlib-shellout-c0173e6b26dff8e8f99a779412eafccb1d2165d0.tar.gz |
Add stderr to live_stream.
-rw-r--r-- | lib/mixlib/shellout.rb | 6 | ||||
-rw-r--r-- | lib/mixlib/shellout/unix.rb | 1 | ||||
-rw-r--r-- | lib/mixlib/shellout/windows.rb | 4 |
3 files changed, 7 insertions, 4 deletions
diff --git a/lib/mixlib/shellout.rb b/lib/mixlib/shellout.rb index a267162..d8e494a 100644 --- a/lib/mixlib/shellout.rb +++ b/lib/mixlib/shellout.rb @@ -53,9 +53,9 @@ module Mixlib # the command was successful. Normally set via options to new attr_accessor :valid_exit_codes - # When live_stream is set, stdout of the subprocess will be copied to it as - # the subprocess is running. For example, if live_stream is set to STDOUT, - # the command's output will be echoed to STDOUT. + # When live_stream is set, stdout and stderr of the subprocess will be + # copied to it as the subprocess is running. For example, if live_stream is + # set to STDOUT, the command's output will be echoed to STDOUT. attr_accessor :live_stream # ShellOut will push data from :input down the stdin of the subprocss. diff --git a/lib/mixlib/shellout/unix.rb b/lib/mixlib/shellout/unix.rb index d7b8b92..489fc7d 100644 --- a/lib/mixlib/shellout/unix.rb +++ b/lib/mixlib/shellout/unix.rb @@ -252,6 +252,7 @@ module Mixlib def read_stderr_to_buffer while chunk = child_stderr.read_nonblock(READ_SIZE) @stderr << chunk + @live_stream << chunk if @live_stream end rescue Errno::EAGAIN rescue EOFError diff --git a/lib/mixlib/shellout/windows.rb b/lib/mixlib/shellout/windows.rb index ea809b5..dcac529 100644 --- a/lib/mixlib/shellout/windows.rb +++ b/lib/mixlib/shellout/windows.rb @@ -165,7 +165,9 @@ module Mixlib if ready.first.include?(stderr_read) begin - @stderr << stderr_read.readpartial(READ_SIZE) + next_chunk = stderr_read.readpartial(READ_SIZE) + @stderr << next_chunk + @live_stream << next_chunk if @live_stream rescue EOFError stderr_read.close open_streams.delete(stderr_read) |