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

Commit

Permalink
Stylistic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Jan 7, 2011
1 parent 0cc96f3 commit 480876e
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions lib/net/ssh/shell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def execute(command, klass=nil, &callback)
process = klass.new(self, command, callback)
process.run if processes.empty?
processes << process
return process
process
end

def subshell(command, &callback)
Expand All @@ -77,7 +77,7 @@ def subshell(command, &callback)
def execute!(command, &callback)
execute(command, &callback)
wait!
return process
process
end

def busy?
Expand Down Expand Up @@ -112,41 +112,41 @@ def on_channel_close(channel)

private

def open_succeeded(channel)
@state = :pty
channel.on_close(&method(:on_channel_close))
channel.request_pty(:modes => { Net::SSH::Connection::Term::ECHO => 0 }, &method(:pty_requested))
end
def open_succeeded(channel)
@state = :pty
channel.on_close(&method(:on_channel_close))
channel.request_pty(:modes => { Net::SSH::Connection::Term::ECHO => 0 }, &method(:pty_requested))
end

def open_failed(channel, code, description)
@state = :closed
raise "could not open channel for process manager (#{description}, ##{code})"
end
def open_failed(channel, code, description)
@state = :closed
raise "could not open channel for process manager (#{description}, ##{code})"
end

def pty_requested(channel, success)
@state = :shell
raise "could not request pty for process manager" unless success
if shell == :default
channel.send_channel_request("shell", &method(:shell_requested))
else
channel.exec(shell, &method(:shell_requested))
end
def pty_requested(channel, success)
@state = :shell
raise "could not request pty for process manager" unless success
if shell == :default
channel.send_channel_request("shell", &method(:shell_requested))
else
channel.exec(shell, &method(:shell_requested))
end
end

def shell_requested(channel, success)
@state = :initializing
raise "could not request shell for process manager" unless success
channel.on_data(&method(:look_for_initialization_done))
channel.send_data "export PS1=; echo #{separator} $?\n"
end
def shell_requested(channel, success)
@state = :initializing
raise "could not request shell for process manager" unless success
channel.on_data(&method(:look_for_initialization_done))
channel.send_data "export PS1=; echo #{separator} $?\n"
end

def look_for_initialization_done(channel, data)
if data.include?(separator)
@state = :open
@when_open.each { |callback| callback.call(self) }
@when_open.clear
end
def look_for_initialization_done(channel, data)
if data.include?(separator)
@state = :open
@when_open.each { |callback| callback.call(self) }
@when_open.clear
end
end
end
end
end
Expand All @@ -158,6 +158,6 @@ class Net::SSH::Connection::Session
def shell(*args)
shell = Net::SSH::Shell.new(self, *args)
yield shell if block_given?
return shell
shell
end
end

0 comments on commit 480876e

Please sign in to comment.