lib/backticks/command.rb in backticks-0.3.0 vs lib/backticks/command.rb in backticks-0.3.1

- old
+ new

@@ -44,12 +44,10 @@ # to Ruby's output streams. If the time limit expires, return `nil`; # otherwise, return self. # # @param [Float,Integer] limit number of seconds to wait before returning def join(limit=nil) - return self if @status # preserve idempotency - if limit tf = Time.now + limit else tf = FOREVER end @@ -75,11 +73,12 @@ # Return up to CHUNK bytes of fresh output from the process, or return nil # if no fresh output was produced # # @param [Float,Integer] number of seconds to wait before returning nil # @return [String,nil] fresh bytes from stdout/stderr, or nil if no output - private def capture(limit=nil) + private + def capture(limit=nil) streams = [@stdout, @stderr] streams << STDIN if interactive? if limit tf = Time.now + limit @@ -115,15 +114,12 @@ if ready && ready.include?(@stderr) data = @stderr.readpartial(CHUNK) rescue nil if data @captured_error << data STDERR.write(data) if interactive? - fresh_error = data end end - - # return freshly-captured text(if any) - fresh_output || fresh_error + fresh_output rescue Interrupt # Proxy Ctrl+C to the child (Process.kill('INT', @pid) rescue nil) if @interactive raise end