Skip to content
This repository was archived by the owner on Oct 31, 2023. It is now read-only.

Commit 1f4bc83

Browse files
committed
Merge branch 'mitchellh/process_stderr'
Conflicts: lib/net/ssh/shell/process.rb
2 parents 2cec3b5 + bd46382 commit 1f4bc83

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/net/ssh/shell/process.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def initialize(manager, command, callback)
1414
@callback = callback
1515
@properties = {}
1616
@on_output = Proc.new { |p, data| print(data) }
17+
@on_error_output = Proc.new { |p, data| print(data) }
1718
@on_finish = nil
1819
@state = :new
1920
end
@@ -36,6 +37,7 @@ def run
3637
manager.open do
3738
state = :running
3839
manager.channel.on_data(&method(:on_stdout))
40+
manager.channel.on_extended_data(&method(:on_stderr))
3941
manager.channel.on_close(&method(:on_close))
4042

4143
cmd = command.dup
@@ -75,6 +77,10 @@ def on_output(&callback)
7577
@on_output = callback
7678
end
7779

80+
def on_error_output(&callback)
81+
@on_error_output = callback
82+
end
83+
7884
def on_finish(&callback)
7985
@on_finish = callback
8086
end
@@ -96,6 +102,11 @@ def on_stdout(ch, data)
96102
end
97103
end
98104

105+
def on_stderr(ch, type, data)
106+
return unless @on_error_output
107+
@on_error_output.call(self, data)
108+
end
109+
99110
def on_close(ch)
100111
manager.on_channel_close(ch)
101112
finished!(-1)

0 commit comments

Comments
 (0)