shells 0.1.20 → 0.1.21
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 +4 -4
- data/lib/shells/serial_session.rb +2 -2
- data/lib/shells/shell_base.rb +21 -15
- data/lib/shells/ssh_session.rb +2 -2
- data/lib/shells/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b47a6e5df048fa8ed1229c13015262da125d6cd2
|
4
|
+
data.tar.gz: 88b2df4f88cfe64c16193d217e9e8d53108407ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2582f949e419ef6652ec454ff6e2be3c8c895f6c45f23fcb43d054812d227a11ee1a2b10059ff4a21c5b0f30cf68dd020180777027dee0234bea37850f894f1d
|
7
|
+
data.tar.gz: 8f132e4aaf642a5c6e2584ce2d0e3a80761458a189ef892f24a981ea2417750aa6b3fc08022bf6c57015824b5de531bd3d4843f389f2029d72d51c47827ac887
|
@@ -138,10 +138,10 @@ module Shells
|
|
138
138
|
else
|
139
139
|
# set the prompt, wait up to 2 seconds for a response, then try one more time.
|
140
140
|
begin
|
141
|
-
exec cmd, command_timeout: 2, retrieve_exit_code: false
|
141
|
+
exec cmd, command_timeout: 2, retrieve_exit_code: false, command_is_echoed: false
|
142
142
|
rescue Shells::CommandTimeout
|
143
143
|
begin
|
144
|
-
exec cmd, command_timeout: 2, retrieve_exit_code: false
|
144
|
+
exec cmd, command_timeout: 2, retrieve_exit_code: false, command_is_echoed: false
|
145
145
|
rescue Shells::CommandTimeout
|
146
146
|
raise Shells::FailedToSetPrompt
|
147
147
|
end
|
data/lib/shells/shell_base.rb
CHANGED
@@ -349,6 +349,7 @@ module Shells
|
|
349
349
|
options[:on_non_zero_exit_code] = self.options[:on_non_zero_exit_code] unless [:raise, :ignore].include?(options[:on_non_zero_exit_code])
|
350
350
|
options[:silence_timeout] = self.options[:silence_timeout] if options[:silence_timeout] == :default
|
351
351
|
options[:command_timeout] = self.options[:command_timeout] if options[:command_timeout] == :default
|
352
|
+
options[:command_is_echoed] = true if options[:command_is_echoed].nil?
|
352
353
|
ret = ''
|
353
354
|
|
354
355
|
begin
|
@@ -365,7 +366,7 @@ module Shells
|
|
365
366
|
if wait_for_prompt(options[:silence_timeout], options[:command_timeout], options[:timeout_error])
|
366
367
|
# get the output of the command, minus the trailing prompt.
|
367
368
|
debug 'Reading output of command...'
|
368
|
-
ret = command_output command
|
369
|
+
ret = command_output command, options[:command_is_echoed]
|
369
370
|
|
370
371
|
if options[:retrieve_exit_code]
|
371
372
|
self.last_exit_code = get_exit_code
|
@@ -794,7 +795,7 @@ module Shells
|
|
794
795
|
data.gsub("\r\n", "\n").gsub(" \r", "").gsub("\r", "")
|
795
796
|
end
|
796
797
|
|
797
|
-
def command_output(command)
|
798
|
+
def command_output(command, expect_command = true)
|
798
799
|
# get everything except for the ending prompt.
|
799
800
|
ret =
|
800
801
|
if (prompt_pos = (combined_output =~ prompt_match))
|
@@ -803,21 +804,26 @@ module Shells
|
|
803
804
|
combined_output
|
804
805
|
end
|
805
806
|
|
806
|
-
command_regex = command_match(command)
|
807
807
|
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
808
|
+
if expect_command
|
809
|
+
command_regex = command_match(command)
|
810
|
+
|
811
|
+
# Go until we run out of data or we find one of the possible command starts.
|
812
|
+
# Note that we EXPECT the command to the first line of the output from the command because we expect the
|
813
|
+
# shell to echo it back to us.
|
814
|
+
result_cmd,_,result_data = ret.partition("\n")
|
815
|
+
until result_data.to_s.strip == '' || result_cmd.strip =~ command_regex
|
816
|
+
result_cmd,_,result_data = result_data.partition("\n")
|
817
|
+
end
|
818
|
+
|
819
|
+
if result_cmd.nil? || !(result_cmd =~ command_regex)
|
820
|
+
STDERR.puts "SHELL WARNING: Failed to match #{command_regex.inspect}."
|
821
|
+
end
|
822
|
+
|
823
|
+
result_data
|
824
|
+
else
|
825
|
+
ret
|
818
826
|
end
|
819
|
-
|
820
|
-
result_data
|
821
827
|
end
|
822
828
|
|
823
829
|
def strip_ansi_escape(data)
|
data/lib/shells/ssh_session.rb
CHANGED
@@ -186,10 +186,10 @@ module Shells
|
|
186
186
|
else
|
187
187
|
# set the prompt, wait up to 2 seconds for a response, then try one more time.
|
188
188
|
begin
|
189
|
-
exec cmd, command_timeout: 2, retrieve_exit_code: false
|
189
|
+
exec cmd, command_timeout: 2, retrieve_exit_code: false, command_is_echoed: false
|
190
190
|
rescue Shells::CommandTimeout
|
191
191
|
begin
|
192
|
-
exec cmd, command_timeout: 2, retrieve_exit_code: false
|
192
|
+
exec cmd, command_timeout: 2, retrieve_exit_code: false, command_is_echoed: false
|
193
193
|
rescue Shells::CommandTimeout
|
194
194
|
raise Shells::FailedToSetPrompt
|
195
195
|
end
|
data/lib/shells/version.rb
CHANGED