mixlib-shellout 3.2.8-universal-mingw32 → 3.3.4-universal-mingw32
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/mixlib/shellout/helper.rb +35 -4
- data/lib/mixlib/shellout/unix.rb +0 -11
- data/lib/mixlib/shellout/version.rb +1 -1
- data/lib/mixlib/shellout/windows.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ce03266c7c25e063524e1ea83e431a15a0bbe8613b23bc11f0f2f4d5e8e7973
|
4
|
+
data.tar.gz: de2b250d95c976d0bf057ae0a1aff77e945a4db9b02a3afc3de0d9db80ce5c1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 067133c65ac5941022338b606481fddba6f7b98a7807a656d9d23e9a1b2ca8d6bdf8288164034ed02db294247e901f03d56f5d5a164514ee3f62cdc0511b7c04
|
7
|
+
data.tar.gz: f83b79d951da8abfa8655c8c96bdfbdffb3be738c385963926402af0d072976b1556dfa868f02c243cb2269baf9798f36189932a20e9cd2309ed8bc08616f35c
|
@@ -141,9 +141,39 @@ module Mixlib
|
|
141
141
|
args.flatten.compact.map(&:to_s)
|
142
142
|
end
|
143
143
|
|
144
|
+
# Join arguments into a string.
|
145
|
+
#
|
146
|
+
# Strips leading/trailing spaces from each argument. If an argument contains
|
147
|
+
# a space, it is quoted. Join into a single string with spaces between each argument.
|
148
|
+
#
|
149
|
+
# @param args [String] variable number of string arguments
|
150
|
+
# @return [String] merged string
|
151
|
+
#
|
152
|
+
def __join_whitespace(*args)
|
153
|
+
args.flatten.map do |arg|
|
154
|
+
arg.strip!
|
155
|
+
arg.include?(" ") ? sprintf('"%s"', arg) : arg
|
156
|
+
end.join(" ")
|
157
|
+
end
|
158
|
+
|
144
159
|
def __shell_out_command(*args, **options)
|
145
160
|
if __transport_connection
|
146
|
-
|
161
|
+
command = __join_whitespace(args)
|
162
|
+
unless ChefUtils.windows?
|
163
|
+
if options[:cwd]
|
164
|
+
# as `timeout` is used, commands need to be executed in a subshell
|
165
|
+
command = "sh -c 'cd #{options[:cwd]}; #{command}'"
|
166
|
+
end
|
167
|
+
|
168
|
+
if options[:input]
|
169
|
+
command.concat "<<'COMMANDINPUT'\n"
|
170
|
+
command.concat __join_whitespace(options[:input])
|
171
|
+
command.concat "COMMANDINPUT\n"
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
# FIXME: train should accept run_command(*args)
|
176
|
+
FakeShellOut.new(args, options, __transport_connection.run_command(command, options))
|
147
177
|
else
|
148
178
|
cmd = if options.empty?
|
149
179
|
Mixlib::ShellOut.new(*args)
|
@@ -181,15 +211,16 @@ module Mixlib
|
|
181
211
|
@stdout = result.stdout
|
182
212
|
@stderr = result.stderr
|
183
213
|
@exitstatus = result.exit_status
|
184
|
-
@
|
214
|
+
@valid_exit_codes = Array(options[:returns] || 0)
|
215
|
+
@status = OpenStruct.new(success?: (@valid_exit_codes.include? exitstatus))
|
185
216
|
end
|
186
217
|
|
187
218
|
def error?
|
188
|
-
exitstatus
|
219
|
+
@valid_exit_codes.none?(exitstatus)
|
189
220
|
end
|
190
221
|
|
191
222
|
def error!
|
192
|
-
raise Mixlib::ShellOut::ShellCommandFailed, "Unexpected exit status of #{exitstatus} running #{@args}" if error?
|
223
|
+
raise Mixlib::ShellOut::ShellCommandFailed, "Unexpected exit status of #{exitstatus} running #{@args}: #{stderr}" if error?
|
193
224
|
end
|
194
225
|
end
|
195
226
|
end
|
data/lib/mixlib/shellout/unix.rb
CHANGED
@@ -20,11 +20,6 @@ module Mixlib
|
|
20
20
|
class ShellOut
|
21
21
|
module Unix
|
22
22
|
|
23
|
-
# "1.8.7" as a frozen string. We use this with a hack that disables GC to
|
24
|
-
# avoid segfaults on Ruby 1.8.7, so we need to allocate the fewest
|
25
|
-
# objects we possibly can.
|
26
|
-
ONE_DOT_EIGHT_DOT_SEVEN = "1.8.7".freeze
|
27
|
-
|
28
23
|
# Option validation that is unix specific
|
29
24
|
def validate_options(opts)
|
30
25
|
if opts[:elevated]
|
@@ -99,12 +94,6 @@ module Mixlib
|
|
99
94
|
|
100
95
|
configure_parent_process_file_descriptors
|
101
96
|
|
102
|
-
# Ruby 1.8.7 and 1.8.6 from mid 2009 try to allocate objects during GC
|
103
|
-
# when calling IO.select and IO#read. Disabling GC works around the
|
104
|
-
# segfault, but obviously it's a bad workaround. We no longer support
|
105
|
-
# 1.8.6 so we only need this hack for 1.8.7.
|
106
|
-
GC.disable if RUBY_VERSION == ONE_DOT_EIGHT_DOT_SEVEN
|
107
|
-
|
108
97
|
# CHEF-3390: Marshall.load on Ruby < 1.8.7p369 also has a GC bug related
|
109
98
|
# to Marshall.load, so try disabling GC first.
|
110
99
|
propagate_pre_exec_failure
|
@@ -60,6 +60,7 @@ module Mixlib
|
|
60
60
|
stderr_read, stderr_write = IO.pipe
|
61
61
|
stdin_read, stdin_write = IO.pipe
|
62
62
|
open_streams = [ stdout_read, stderr_read ]
|
63
|
+
@execution_time = 0
|
63
64
|
|
64
65
|
begin
|
65
66
|
|
@@ -105,6 +106,8 @@ module Mixlib
|
|
105
106
|
wait_status = WaitForSingleObject(process.process_handle, 0)
|
106
107
|
case wait_status
|
107
108
|
when WAIT_OBJECT_0
|
109
|
+
# Save the execution time
|
110
|
+
@execution_time = Time.now - start_wait
|
108
111
|
# Get process exit code
|
109
112
|
exit_code = [0].pack("l")
|
110
113
|
unless GetExitCodeProcess(process.process_handle, exit_code)
|
@@ -127,6 +130,9 @@ module Mixlib
|
|
127
130
|
logger&.warn("Failed to kill timed out process #{process.process_id}")
|
128
131
|
end
|
129
132
|
|
133
|
+
# Save the execution time
|
134
|
+
@execution_time = Time.now - start_wait
|
135
|
+
|
130
136
|
raise Mixlib::ShellOut::CommandTimeout, [
|
131
137
|
"command timed out:",
|
132
138
|
format_for_exception,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mixlib-shellout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.4
|
5
5
|
platform: universal-mingw32
|
6
6
|
authors:
|
7
7
|
- Chef Software Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef-utils
|