shells 0.1.22 → 0.1.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 740e75fa474c1a977a1ad064cf3cb7da8be71c7a
4
- data.tar.gz: 6f420afb22bbc58711c7b81da0ee3c709645b2b6
3
+ metadata.gz: 79a5181a0a44f0f7f3f58fa2d8016e882e1a0a85
4
+ data.tar.gz: 93cac3a6699467509be0e4165fa21c91b727d77e
5
5
  SHA512:
6
- metadata.gz: b4cafdbf8b707bb08cb2d96dd3aefde829509200bdbb0e1770598bd0fa6e88d70f828894dc1794fbbcbfe552d697fd99d1369c6052b30b6eb7e939b6adc03f11
7
- data.tar.gz: dfaeb51d1e5afe10ab2ed30589c64f7319b09d065532a37d63e65b92db1480b041a400362438db10b4124b1eed577459fb3bf16b3e80ba2d757a5e9c857566a0
6
+ metadata.gz: fd579203b87620a7d14bf40a31dbbeb5e4d4c66f13ac8b0e93fdca5b19de39c67ac63c0054359a03ed26a740aede2e624604ed017ab5270a5fdc5859098cecc9
7
+ data.tar.gz: 40a853476c627024cb33386434f7b3d612078ada71fd81f80d7287f767812e1e9a32daf5bba58f1d92c4663a69c90fff87f71c76c69eef4eb50e69b17ba8af85
@@ -545,6 +545,8 @@ module Shells
545
545
  end
546
546
 
547
547
  loop do
548
+ Thread.pass
549
+
548
550
  last_input = @last_input
549
551
 
550
552
  # Do we need to nudge the shell?
@@ -32,7 +32,9 @@ module Shells
32
32
  # resulting prompt can very easily become something else entirely. If they are provided, they will be
33
33
  # replaced to protect the shell from getting stuck.
34
34
  # +shell+::
35
- # If set to :shell, then the default shell is executed.
35
+ # If set to :shell, then the default shell is executed. This is the default value.
36
+ # If set to :none, then no shell is executed, but a PTY is still created.
37
+ # If set to :no_pty, then no shell is executed and no PTY is created.
36
38
  # If set to anything else, it is assumed to be the executable path to the shell you want to run.
37
39
  # +quit+::
38
40
  # If set, this defines the command to execute when quitting the session.
@@ -132,33 +134,38 @@ module Shells
132
134
  # open the channel
133
135
  debug 'Opening channel...'
134
136
  @channel = ssh.open_channel do |ch|
135
- # request a PTY
136
- debug 'Requesting PTY...'
137
- ch.request_pty do |ch_pty, success_pty|
138
- raise FailedToRequestPty unless success_pty
139
-
140
- # pick a method to start the shell with.
141
- meth = (options[:shell] == :shell) ? :send_channel_request : :exec
142
-
143
- buffer_input
144
-
145
- # start the shell
146
- debug 'Starting shell...'
147
- ch_pty.send(meth, options[:shell].to_s) do |ch_sh, success_sh|
148
- raise FailedToStartShell unless success_sh
149
-
150
- # give the shell a chance to get ready.
151
- sleep 0.25
152
-
153
- begin
154
- # yield to the block
155
- block.call
156
-
157
- ensure
158
- # send the exit command.
159
- ignore_io_error = true
160
- debug 'Closing connection...'
161
- send_data options[:quit] + line_ending
137
+ # start buffering the channel output.
138
+ buffer_input
139
+
140
+ if options[:shell] == :no_pty
141
+ debug 'Executing session without PTY...'
142
+
143
+ ssh_exec_session &block
144
+ else
145
+ # request a PTY
146
+ debug 'Requesting PTY...'
147
+ ch.request_pty do |ch_pty, success_pty|
148
+ raise FailedToRequestPty unless success_pty
149
+
150
+ if options[:shell] == :none
151
+ debug 'Executing session without shell...'
152
+
153
+ ssh_exec_session &block
154
+ else
155
+ # pick a method to start the shell with.
156
+ meth = (options[:shell] == :shell) ? :send_channel_request : :exec
157
+
158
+ # start the shell
159
+ debug 'Starting shell...'
160
+ ch_pty.send(meth, options[:shell].to_s) do |ch_sh, success_sh|
161
+ raise FailedToStartShell unless success_sh
162
+
163
+ # give the shell a chance to get ready.
164
+ sleep 0.25
165
+
166
+ debug 'Executing session in shell...'
167
+ ssh_exec_session &block
168
+ end
162
169
  end
163
170
  end
164
171
  end
@@ -225,5 +232,18 @@ module Shells
225
232
  end
226
233
  end
227
234
 
235
+ private
236
+
237
+ def ssh_exec_session(&block)
238
+ begin
239
+ block.call
240
+ ensure
241
+ # send the exit command.
242
+ ignore_io_error = true
243
+ debug 'Closing connection...'
244
+ send_data options[:quit] + line_ending
245
+ end
246
+ end
247
+
228
248
  end
229
249
  end
@@ -1,3 +1,3 @@
1
1
  module Shells
2
- VERSION = "0.1.22"
2
+ VERSION = "0.1.23"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shells
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.22
4
+ version: 0.1.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Beau Barker