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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8a2ba35d263f193785009154e37b502bcfdb16db
4
- data.tar.gz: fc7c24f3388a2d992cf919fa8bbc930adcf4f473
3
+ metadata.gz: b47a6e5df048fa8ed1229c13015262da125d6cd2
4
+ data.tar.gz: 88b2df4f88cfe64c16193d217e9e8d53108407ea
5
5
  SHA512:
6
- metadata.gz: 73072e5a54ae4fcc53db8ab731d9ee912183fa50489c787f1f5088e72f4a5be0dfdac08ec131223fd89fd30cb4491c832288510f4b8e69be032dc9a74a402198
7
- data.tar.gz: 02f61d4eda6f334c68ccf94426083c304e7c88d935cc09a41f68e1f68b34b688c427c8ff4cb41d2efcb8c5073900529c4e22775b49e31b07cda31eadfeb8f710
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
@@ -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
- # Go until we run out of data or we find one of the possible command starts.
809
- # Note that we EXPECT the command to the first line of the output from the command because we expect the
810
- # shell to echo it back to us.
811
- result_cmd,_,result_data = ret.partition("\n")
812
- until result_data.to_s.strip == '' || result_cmd.strip =~ command_regex
813
- result_cmd,_,result_data = result_data.partition("\n")
814
- end
815
-
816
- if result_cmd.nil? || !(result_cmd =~ command_regex)
817
- STDERR.puts "SHELL WARNING: Failed to match #{command_regex.inspect}."
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)
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Shells
2
- VERSION = "0.1.20"
2
+ VERSION = "0.1.21"
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.20
4
+ version: 0.1.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Beau Barker