Skip to content

Commit

Permalink
Do not mutate @stdout or @stderr strings
Browse files Browse the repository at this point in the history
Calling @stdout.clear broke airbrussh, and was hard to debug. This commit restores the previous (better) behaviour of simply assigning a new blank string when clearing.
  • Loading branch information
robd committed May 5, 2015
1 parent 0b195d3 commit e93f819
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/sshkit/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def on_stdout(channel, data)
end

def clear_stdout_lines
split_and_clear_stream(@stdout)
split_and_clear_stream(:@stdout)
end

def on_stderr(channel, data)
Expand All @@ -73,7 +73,7 @@ def on_stderr(channel, data)
end

def clear_stderr_lines
split_and_clear_stream(@stderr)
split_and_clear_stream(:@stderr)
end

def exit_status=(new_exit_status)
Expand Down Expand Up @@ -220,8 +220,9 @@ def sanitize_command!
end
end

def split_and_clear_stream(stream)
stream.lines.to_a.tap { stream.clear } # Convert lines enumerable to an array for ruby 1.9
def split_and_clear_stream(stream_name)
# Convert lines enumerable to an array for ruby 1.9
instance_variable_get(stream_name).lines.to_a.tap { instance_variable_set(stream_name, '') }
end

def call_interaction_handler(channel, data, callback_name)
Expand Down

0 comments on commit e93f819

Please sign in to comment.