mixlib-shellout 1.0.0.rc.1-x86-mingw32 → 1.0.0-x86-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.
- data/lib/mixlib/shellout/unix.rb +2 -2
- data/lib/mixlib/shellout/version.rb +1 -1
- data/lib/mixlib/shellout/windows.rb +45 -11
- metadata +41 -34
data/lib/mixlib/shellout/unix.rb
CHANGED
@@ -185,7 +185,7 @@ module Mixlib
|
|
185
185
|
end
|
186
186
|
rescue Errno::EAGAIN
|
187
187
|
rescue EOFError
|
188
|
-
open_pipes.
|
188
|
+
open_pipes.delete(child_stdout)
|
189
189
|
end
|
190
190
|
|
191
191
|
def read_stderr_to_buffer
|
@@ -194,7 +194,7 @@ module Mixlib
|
|
194
194
|
end
|
195
195
|
rescue Errno::EAGAIN
|
196
196
|
rescue EOFError
|
197
|
-
open_pipes.
|
197
|
+
open_pipes.delete(child_stderr)
|
198
198
|
end
|
199
199
|
|
200
200
|
def fork_subprocess
|
@@ -42,6 +42,7 @@ module Mixlib
|
|
42
42
|
#
|
43
43
|
stdout_read, stdout_write = IO.pipe
|
44
44
|
stderr_read, stderr_write = IO.pipe
|
45
|
+
stdin_read, stdin_write = IO.pipe
|
45
46
|
open_streams = [ stdout_read, stderr_read ]
|
46
47
|
|
47
48
|
begin
|
@@ -55,7 +56,8 @@ module Mixlib
|
|
55
56
|
:command_line => command_line,
|
56
57
|
:startup_info => {
|
57
58
|
:stdout => stdout_write,
|
58
|
-
:stderr => stderr_write
|
59
|
+
:stderr => stderr_write,
|
60
|
+
:stdin => stdin_read
|
59
61
|
},
|
60
62
|
:environment => inherit_environment.map { |k,v| "#{k}=#{v}" },
|
61
63
|
:close_handles => false
|
@@ -88,7 +90,7 @@ module Mixlib
|
|
88
90
|
when WAIT_TIMEOUT
|
89
91
|
# Kill the process
|
90
92
|
if (Time.now - start_wait) > timeout
|
91
|
-
raise Mixlib::ShellOut::CommandTimeout, "command timed out:\n#{format_for_exception}"
|
93
|
+
raise Mixlib::ShellOut::Exceptions::CommandTimeout, "command timed out:\n#{format_for_exception}"
|
92
94
|
end
|
93
95
|
|
94
96
|
consume_output(open_streams, stdout_read, stderr_read)
|
@@ -119,6 +121,9 @@ module Mixlib
|
|
119
121
|
|
120
122
|
class ThingThatLooksSortOfLikeAProcessStatus
|
121
123
|
attr_accessor :exitstatus
|
124
|
+
def success?
|
125
|
+
exitstatus == 0
|
126
|
+
end
|
122
127
|
end
|
123
128
|
|
124
129
|
def consume_output(open_streams, stdout_read, stderr_read)
|
@@ -149,13 +154,33 @@ module Mixlib
|
|
149
154
|
return true
|
150
155
|
end
|
151
156
|
|
152
|
-
|
157
|
+
IS_BATCH_FILE = /\.bat|\.cmd$/i
|
153
158
|
|
154
159
|
def command_to_run
|
155
|
-
if command =~
|
160
|
+
if command =~ /^\s*"(.*)"/
|
161
|
+
# If we have quotes, do an exact match
|
162
|
+
candidate = $1
|
163
|
+
else
|
164
|
+
# Otherwise check everything up to the first space
|
165
|
+
candidate = command[0,command.index(/\s/) || command.length].strip
|
166
|
+
end
|
167
|
+
|
168
|
+
# Don't do searching for empty commands. Let it fail when it runs.
|
169
|
+
if candidate.length == 0
|
170
|
+
return [ nil, command ]
|
171
|
+
end
|
172
|
+
|
173
|
+
# Check if the exe exists directly. Otherwise, search PATH.
|
174
|
+
exe = find_exe_at_location(candidate)
|
175
|
+
if exe.nil? && exe !~ /[\\\/]/
|
176
|
+
exe = which(command[0,command.index(/\s/) || command.length])
|
177
|
+
end
|
178
|
+
|
179
|
+
if exe.nil? || exe =~ IS_BATCH_FILE
|
180
|
+
# Batch files MUST use cmd; and if we couldn't find the command we're looking for, we assume it must be a cmd builtin.
|
156
181
|
[ ENV['COMSPEC'], "cmd /c #{command}" ]
|
157
182
|
else
|
158
|
-
[
|
183
|
+
[ exe, command ]
|
159
184
|
end
|
160
185
|
end
|
161
186
|
|
@@ -175,14 +200,23 @@ module Mixlib
|
|
175
200
|
result
|
176
201
|
end
|
177
202
|
|
203
|
+
def pathext
|
204
|
+
@pathext ||= ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') + [''] : ['']
|
205
|
+
end
|
206
|
+
|
178
207
|
def which(cmd)
|
179
|
-
return cmd if File.executable? cmd
|
180
|
-
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') + [''] : ['']
|
181
208
|
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
209
|
+
exe = find_exe_at_location("#{path}/${cmd}")
|
210
|
+
return exe if exe
|
211
|
+
end
|
212
|
+
return nil
|
213
|
+
end
|
214
|
+
|
215
|
+
def find_exe_at_location(path)
|
216
|
+
return path if File.executable? path
|
217
|
+
pathext.each do |ext|
|
218
|
+
exe = "#{path}#{ext}"
|
219
|
+
return exe if File.executable? exe
|
186
220
|
end
|
187
221
|
return nil
|
188
222
|
end
|
metadata
CHANGED
@@ -1,46 +1,49 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: mixlib-shellout
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 1.0.0
|
6
6
|
platform: x86-mingw32
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Opscode
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
|
13
|
+
date: 2012-02-28 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
15
16
|
name: rspec
|
16
|
-
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
19
|
none: false
|
18
|
-
requirements:
|
19
|
-
- -
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version:
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
22
24
|
type: :development
|
23
|
-
|
24
|
-
|
25
|
-
- !ruby/object:Gem::Dependency
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
26
27
|
name: win32-process
|
27
|
-
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
28
30
|
none: false
|
29
|
-
requirements:
|
31
|
+
requirements:
|
30
32
|
- - ~>
|
31
|
-
- !ruby/object:Gem::Version
|
33
|
+
- !ruby/object:Gem::Version
|
32
34
|
version: 0.6.5
|
33
35
|
type: :runtime
|
34
|
-
|
35
|
-
version_requirements: *70226436346120
|
36
|
+
version_requirements: *id002
|
36
37
|
description: Run external commands on Unix or Windows
|
37
38
|
email: info@opscode.com
|
38
39
|
executables: []
|
40
|
+
|
39
41
|
extensions: []
|
40
|
-
|
42
|
+
|
43
|
+
extra_rdoc_files:
|
41
44
|
- README.md
|
42
45
|
- LICENSE
|
43
|
-
files:
|
46
|
+
files:
|
44
47
|
- LICENSE
|
45
48
|
- README.md
|
46
49
|
- lib/mixlib/shellout/exceptions.rb
|
@@ -50,26 +53,30 @@ files:
|
|
50
53
|
- lib/mixlib/shellout.rb
|
51
54
|
homepage: http://wiki.opscode.com/
|
52
55
|
licenses: []
|
56
|
+
|
53
57
|
post_install_message:
|
54
58
|
rdoc_options: []
|
55
|
-
|
59
|
+
|
60
|
+
require_paths:
|
56
61
|
- lib
|
57
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
63
|
none: false
|
59
|
-
requirements:
|
60
|
-
- -
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version:
|
63
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0"
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
69
|
none: false
|
65
|
-
requirements:
|
66
|
-
- -
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version:
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: "0"
|
69
74
|
requirements: []
|
75
|
+
|
70
76
|
rubyforge_project:
|
71
77
|
rubygems_version: 1.8.10
|
72
78
|
signing_key:
|
73
79
|
specification_version: 3
|
74
80
|
summary: Run external commands on Unix or Windows
|
75
81
|
test_files: []
|
82
|
+
|