rbs 4.0.0.dev.4 → 4.0.0.dev.5

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.
Files changed (223) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +14 -14
  3. data/.github/workflows/bundle-update.yml +60 -0
  4. data/.github/workflows/c-check.yml +11 -8
  5. data/.github/workflows/comments.yml +3 -3
  6. data/.github/workflows/dependabot.yml +1 -1
  7. data/.github/workflows/ruby.yml +17 -34
  8. data/.github/workflows/typecheck.yml +2 -2
  9. data/.github/workflows/valgrind.yml +42 -0
  10. data/.github/workflows/windows.yml +2 -2
  11. data/.rubocop.yml +1 -1
  12. data/README.md +1 -1
  13. data/Rakefile +32 -5
  14. data/config.yml +46 -0
  15. data/core/array.rbs +96 -46
  16. data/core/binding.rbs +0 -2
  17. data/core/builtin.rbs +2 -2
  18. data/core/comparable.rbs +13 -6
  19. data/core/complex.rbs +55 -41
  20. data/core/dir.rbs +4 -4
  21. data/core/encoding.rbs +7 -10
  22. data/core/enumerable.rbs +90 -3
  23. data/core/enumerator/arithmetic_sequence.rbs +70 -0
  24. data/core/enumerator.rbs +63 -1
  25. data/core/errno.rbs +8 -0
  26. data/core/errors.rbs +28 -1
  27. data/core/exception.rbs +2 -2
  28. data/core/fiber.rbs +40 -20
  29. data/core/file.rbs +108 -78
  30. data/core/file_test.rbs +1 -1
  31. data/core/float.rbs +225 -69
  32. data/core/gc.rbs +417 -281
  33. data/core/hash.rbs +1023 -727
  34. data/core/integer.rbs +104 -110
  35. data/core/io/buffer.rbs +21 -10
  36. data/core/io/wait.rbs +11 -33
  37. data/core/io.rbs +82 -19
  38. data/core/kernel.rbs +70 -59
  39. data/core/marshal.rbs +1 -1
  40. data/core/match_data.rbs +1 -1
  41. data/core/math.rbs +42 -3
  42. data/core/method.rbs +63 -27
  43. data/core/module.rbs +103 -26
  44. data/core/nil_class.rbs +3 -3
  45. data/core/numeric.rbs +43 -35
  46. data/core/object.rbs +3 -3
  47. data/core/object_space.rbs +21 -15
  48. data/core/pathname.rbs +1272 -0
  49. data/core/proc.rbs +30 -25
  50. data/core/process.rbs +4 -2
  51. data/core/ractor.rbs +361 -509
  52. data/core/random.rbs +17 -0
  53. data/core/range.rbs +113 -16
  54. data/core/rational.rbs +56 -85
  55. data/core/rbs/unnamed/argf.rbs +2 -2
  56. data/core/rbs/unnamed/env_class.rbs +1 -1
  57. data/core/rbs/unnamed/random.rbs +4 -113
  58. data/core/regexp.rbs +25 -20
  59. data/core/ruby.rbs +53 -0
  60. data/core/ruby_vm.rbs +6 -4
  61. data/core/rubygems/errors.rbs +3 -70
  62. data/core/rubygems/rubygems.rbs +11 -79
  63. data/core/rubygems/version.rbs +2 -3
  64. data/core/set.rbs +488 -359
  65. data/core/signal.rbs +24 -14
  66. data/core/string.rbs +3171 -1241
  67. data/core/struct.rbs +1 -1
  68. data/core/symbol.rbs +17 -11
  69. data/core/thread.rbs +95 -33
  70. data/core/time.rbs +35 -9
  71. data/core/trace_point.rbs +7 -4
  72. data/core/unbound_method.rbs +14 -6
  73. data/docs/aliases.md +79 -0
  74. data/docs/collection.md +2 -2
  75. data/docs/encoding.md +56 -0
  76. data/docs/gem.md +0 -1
  77. data/docs/inline.md +470 -0
  78. data/docs/sigs.md +3 -3
  79. data/docs/syntax.md +33 -4
  80. data/docs/type_fingerprint.md +21 -0
  81. data/exe/rbs +1 -1
  82. data/ext/rbs_extension/ast_translation.c +77 -3
  83. data/ext/rbs_extension/ast_translation.h +3 -0
  84. data/ext/rbs_extension/class_constants.c +8 -2
  85. data/ext/rbs_extension/class_constants.h +4 -0
  86. data/ext/rbs_extension/extconf.rb +5 -1
  87. data/ext/rbs_extension/legacy_location.c +5 -5
  88. data/ext/rbs_extension/main.c +37 -20
  89. data/include/rbs/ast.h +85 -38
  90. data/include/rbs/defines.h +27 -0
  91. data/include/rbs/lexer.h +30 -11
  92. data/include/rbs/parser.h +6 -6
  93. data/include/rbs/string.h +0 -2
  94. data/include/rbs/util/rbs_allocator.h +34 -13
  95. data/include/rbs/util/rbs_assert.h +12 -1
  96. data/include/rbs/util/rbs_encoding.h +2 -0
  97. data/include/rbs/util/rbs_unescape.h +2 -1
  98. data/lib/rbs/ast/annotation.rb +1 -1
  99. data/lib/rbs/ast/comment.rb +1 -1
  100. data/lib/rbs/ast/declarations.rb +10 -10
  101. data/lib/rbs/ast/members.rb +14 -14
  102. data/lib/rbs/ast/ruby/annotations.rb +137 -0
  103. data/lib/rbs/ast/ruby/comment_block.rb +24 -0
  104. data/lib/rbs/ast/ruby/declarations.rb +198 -3
  105. data/lib/rbs/ast/ruby/helpers/constant_helper.rb +4 -0
  106. data/lib/rbs/ast/ruby/members.rb +159 -1
  107. data/lib/rbs/ast/type_param.rb +24 -4
  108. data/lib/rbs/buffer.rb +20 -15
  109. data/lib/rbs/cli/diff.rb +16 -15
  110. data/lib/rbs/cli/validate.rb +38 -51
  111. data/lib/rbs/cli.rb +52 -19
  112. data/lib/rbs/collection/config/lockfile_generator.rb +8 -0
  113. data/lib/rbs/collection/sources/git.rb +1 -0
  114. data/lib/rbs/definition.rb +1 -1
  115. data/lib/rbs/definition_builder/ancestor_builder.rb +62 -9
  116. data/lib/rbs/definition_builder/method_builder.rb +20 -0
  117. data/lib/rbs/definition_builder.rb +91 -2
  118. data/lib/rbs/diff.rb +7 -1
  119. data/lib/rbs/environment.rb +227 -74
  120. data/lib/rbs/environment_loader.rb +0 -6
  121. data/lib/rbs/errors.rb +27 -7
  122. data/lib/rbs/inline_parser.rb +341 -5
  123. data/lib/rbs/location_aux.rb +1 -1
  124. data/lib/rbs/locator.rb +5 -1
  125. data/lib/rbs/method_type.rb +5 -3
  126. data/lib/rbs/parser_aux.rb +2 -2
  127. data/lib/rbs/prototype/rb.rb +2 -2
  128. data/lib/rbs/prototype/rbi.rb +2 -0
  129. data/lib/rbs/prototype/runtime.rb +8 -0
  130. data/lib/rbs/resolver/constant_resolver.rb +2 -2
  131. data/lib/rbs/resolver/type_name_resolver.rb +116 -38
  132. data/lib/rbs/subtractor.rb +3 -1
  133. data/lib/rbs/test/type_check.rb +16 -2
  134. data/lib/rbs/type_name.rb +1 -1
  135. data/lib/rbs/types.rb +27 -27
  136. data/lib/rbs/validator.rb +2 -2
  137. data/lib/rbs/version.rb +1 -1
  138. data/lib/rbs.rb +1 -1
  139. data/lib/rdoc/discover.rb +1 -1
  140. data/lib/rdoc_plugin/parser.rb +1 -1
  141. data/rbs.gemspec +3 -2
  142. data/schema/typeParam.json +17 -1
  143. data/sig/ast/ruby/annotations.rbs +124 -0
  144. data/sig/ast/ruby/comment_block.rbs +8 -0
  145. data/sig/ast/ruby/declarations.rbs +102 -4
  146. data/sig/ast/ruby/members.rbs +87 -1
  147. data/sig/cli/diff.rbs +5 -11
  148. data/sig/cli/validate.rbs +13 -4
  149. data/sig/cli.rbs +18 -18
  150. data/sig/definition.rbs +6 -1
  151. data/sig/environment.rbs +70 -12
  152. data/sig/errors.rbs +13 -6
  153. data/sig/inline_parser.rbs +39 -2
  154. data/sig/locator.rbs +0 -2
  155. data/sig/manifest.yaml +0 -1
  156. data/sig/method_builder.rbs +3 -1
  157. data/sig/method_types.rbs +1 -1
  158. data/sig/parser.rbs +16 -2
  159. data/sig/resolver/type_name_resolver.rbs +35 -7
  160. data/sig/source.rbs +3 -3
  161. data/sig/type_param.rbs +13 -8
  162. data/sig/types.rbs +4 -4
  163. data/src/ast.c +80 -1
  164. data/src/lexer.c +1392 -1313
  165. data/src/lexer.re +3 -0
  166. data/src/lexstate.c +58 -37
  167. data/src/location.c +4 -4
  168. data/src/parser.c +412 -145
  169. data/src/string.c +0 -48
  170. data/src/util/rbs_allocator.c +89 -71
  171. data/src/util/rbs_assert.c +1 -1
  172. data/src/util/rbs_buffer.c +2 -2
  173. data/src/util/rbs_constant_pool.c +10 -10
  174. data/src/util/rbs_encoding.c +4 -8
  175. data/src/util/rbs_unescape.c +56 -20
  176. data/stdlib/bigdecimal/0/big_decimal.rbs +100 -82
  177. data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
  178. data/stdlib/cgi/0/core.rbs +9 -393
  179. data/stdlib/cgi/0/manifest.yaml +1 -0
  180. data/stdlib/cgi-escape/0/escape.rbs +171 -0
  181. data/stdlib/coverage/0/coverage.rbs +3 -1
  182. data/stdlib/date/0/date.rbs +67 -59
  183. data/stdlib/date/0/date_time.rbs +1 -1
  184. data/stdlib/delegate/0/delegator.rbs +10 -7
  185. data/stdlib/digest/0/digest.rbs +110 -0
  186. data/stdlib/erb/0/erb.rbs +737 -347
  187. data/stdlib/fileutils/0/fileutils.rbs +20 -14
  188. data/stdlib/forwardable/0/forwardable.rbs +3 -0
  189. data/stdlib/json/0/json.rbs +82 -28
  190. data/stdlib/net-http/0/net-http.rbs +3 -0
  191. data/stdlib/objspace/0/objspace.rbs +9 -27
  192. data/stdlib/open-uri/0/open-uri.rbs +40 -0
  193. data/stdlib/open3/0/open3.rbs +459 -1
  194. data/stdlib/openssl/0/openssl.rbs +331 -228
  195. data/stdlib/optparse/0/optparse.rbs +8 -3
  196. data/stdlib/pathname/0/pathname.rbs +9 -1379
  197. data/stdlib/psych/0/psych.rbs +4 -4
  198. data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
  199. data/stdlib/rdoc/0/code_object.rbs +2 -1
  200. data/stdlib/rdoc/0/parser.rbs +1 -1
  201. data/stdlib/rdoc/0/rdoc.rbs +1 -1
  202. data/stdlib/rdoc/0/store.rbs +1 -1
  203. data/stdlib/resolv/0/resolv.rbs +25 -68
  204. data/stdlib/ripper/0/ripper.rbs +2 -2
  205. data/stdlib/securerandom/0/manifest.yaml +2 -0
  206. data/stdlib/securerandom/0/securerandom.rbs +6 -19
  207. data/stdlib/singleton/0/singleton.rbs +3 -0
  208. data/stdlib/socket/0/socket.rbs +13 -1
  209. data/stdlib/socket/0/tcp_socket.rbs +10 -2
  210. data/stdlib/stringio/0/stringio.rbs +1176 -85
  211. data/stdlib/strscan/0/string_scanner.rbs +31 -31
  212. data/stdlib/tempfile/0/tempfile.rbs +3 -3
  213. data/stdlib/time/0/time.rbs +1 -1
  214. data/stdlib/timeout/0/timeout.rbs +63 -7
  215. data/stdlib/tsort/0/cyclic.rbs +3 -0
  216. data/stdlib/uri/0/common.rbs +16 -2
  217. data/stdlib/uri/0/file.rbs +1 -1
  218. data/stdlib/uri/0/generic.rbs +24 -16
  219. data/stdlib/uri/0/rfc2396_parser.rbs +6 -7
  220. data/stdlib/zlib/0/gzip_reader.rbs +2 -2
  221. data/stdlib/zlib/0/gzip_writer.rbs +1 -1
  222. data/stdlib/zlib/0/zstream.rbs +1 -0
  223. metadata +30 -4
@@ -48,6 +48,106 @@
48
48
  # Options](rdoc-ref:Process@Execution+Options).
49
49
  #
50
50
  module Open3
51
+ type env = Hash[String, String]
52
+
53
+ # <!--
54
+ # rdoc-file=lib/open3.rb
55
+ # - Open3.capture2([env, ] command_line, options = {}) -> [stdout_s, status]
56
+ # - Open3.capture2([env, ] exe_path, *args, options = {}) -> [stdout_s, status]
57
+ # -->
58
+ # Basically a wrapper for Open3.popen3 that:
59
+ #
60
+ # * Creates a child process, by calling Open3.popen3 with the given arguments
61
+ # (except for certain entries in hash `options`; see below).
62
+ # * Returns as string `stdout_s` the standard output of the child process.
63
+ # * Returns as `status` a `Process::Status` object that represents the exit
64
+ # status of the child process.
65
+ #
66
+ # Returns the array `[stdout_s, status]`:
67
+ #
68
+ # stdout_s, status = Open3.capture2('echo "Foo"')
69
+ # # => ["Foo\n", #<Process::Status: pid 2326047 exit 0>]
70
+ #
71
+ # Like Process.spawn, this method has potential security vulnerabilities if
72
+ # called with untrusted input; see [Command
73
+ # Injection](rdoc-ref:command_injection.rdoc@Command+Injection).
74
+ #
75
+ # Unlike Process.spawn, this method waits for the child process to exit before
76
+ # returning, so the caller need not do so.
77
+ #
78
+ # If the first argument is a hash, it becomes leading argument `env` in the call
79
+ # to Open3.popen3; see [Execution
80
+ # Environment](rdoc-ref:Process@Execution+Environment).
81
+ #
82
+ # If the last argument is a hash, it becomes trailing argument `options` in the
83
+ # call to Open3.popen3; see [Execution
84
+ # Options](rdoc-ref:Process@Execution+Options).
85
+ #
86
+ # The hash `options` is given; two options have local effect in method
87
+ # Open3.capture2:
88
+ #
89
+ # * If entry `options[:stdin_data]` exists, the entry is removed and its
90
+ # string value is sent to the command's standard input:
91
+ #
92
+ # Open3.capture2('tee', stdin_data: 'Foo')
93
+ #
94
+ # # => ["Foo", #<Process::Status: pid 2326087 exit 0>]
95
+ #
96
+ # * If entry `options[:binmode]` exists, the entry is removed and the internal
97
+ # streams are set to binary mode.
98
+ #
99
+ # The single required argument is one of the following:
100
+ #
101
+ # * `command_line` if it is a string, and if it begins with a shell reserved
102
+ # word or special built-in, or if it contains one or more metacharacters.
103
+ # * `exe_path` otherwise.
104
+ #
105
+ # **Argument `command_line`**
106
+ #
107
+ # String argument `command_line` is a command line to be passed to a shell; it
108
+ # must begin with a shell reserved word, begin with a special built-in, or
109
+ # contain meta characters:
110
+ #
111
+ # Open3.capture2('if true; then echo "Foo"; fi') # Shell reserved word.
112
+ # # => ["Foo\n", #<Process::Status: pid 2326131 exit 0>]
113
+ # Open3.capture2('echo') # Built-in.
114
+ # # => ["\n", #<Process::Status: pid 2326139 exit 0>]
115
+ # Open3.capture2('date > date.tmp') # Contains meta character.
116
+ # # => ["", #<Process::Status: pid 2326174 exit 0>]
117
+ #
118
+ # The command line may also contain arguments and options for the command:
119
+ #
120
+ # Open3.capture2('echo "Foo"')
121
+ # # => ["Foo\n", #<Process::Status: pid 2326183 exit 0>]
122
+ #
123
+ # **Argument `exe_path`**
124
+ #
125
+ # Argument `exe_path` is one of the following:
126
+ #
127
+ # * The string path to an executable to be called.
128
+ # * A 2-element array containing the path to an executable and the string to
129
+ # be used as the name of the executing process.
130
+ #
131
+ # Example:
132
+ #
133
+ # Open3.capture2('/usr/bin/date')
134
+ # # => ["Fri Sep 29 01:00:39 PM CDT 2023\n", #<Process::Status: pid 2326222 exit 0>]
135
+ #
136
+ # Ruby invokes the executable directly, with no shell and no shell expansion:
137
+ #
138
+ # Open3.capture2('doesnt_exist') # Raises Errno::ENOENT
139
+ #
140
+ # If one or more `args` is given, each is an argument or option to be passed to
141
+ # the executable:
142
+ #
143
+ # Open3.capture2('echo', 'C #')
144
+ # # => ["C #\n", #<Process::Status: pid 2326267 exit 0>]
145
+ # Open3.capture2('echo', 'hello', 'world')
146
+ # # => ["hello world\n", #<Process::Status: pid 2326299 exit 0>]
147
+ #
148
+ def self?.capture2: (*String, ?stdin_data: String, ?binmode: boolish) -> [String, Process::Status]
149
+ | (env, *String, ?stdin_data: String, ?binmode: boolish) -> [String, Process::Status]
150
+
51
151
  # <!--
52
152
  # rdoc-file=lib/open3.rb
53
153
  # - Open3.capture2e([env, ] command_line, options = {}) -> [stdout_and_stderr_s, status]
@@ -143,5 +243,363 @@ module Open3
143
243
  # Open3.capture2e('echo', 'hello', 'world')
144
244
  # # => ["hello world\n", #<Process::Status: pid 2371894 exit 0>]
145
245
  #
146
- def self.capture2e: (*String, ?stdin_data: String, ?binmode: boolish) -> [String, Process::Status]
246
+ def self?.capture2e: (*String, ?stdin_data: String, ?binmode: boolish) -> [String, Process::Status]
247
+ | (env, *String, ?stdin_data: String, ?binmode: boolish) -> [String, Process::Status]
248
+
249
+ # <!--
250
+ # rdoc-file=lib/open3.rb
251
+ # - Open3.capture3([env, ] command_line, options = {}) -> [stdout_s, stderr_s, status]
252
+ # - Open3.capture3([env, ] exe_path, *args, options = {}) -> [stdout_s, stderr_s, status]
253
+ # -->
254
+ # Basically a wrapper for Open3.popen3 that:
255
+ #
256
+ # * Creates a child process, by calling Open3.popen3 with the given arguments
257
+ # (except for certain entries in hash `options`; see below).
258
+ # * Returns as strings `stdout_s` and `stderr_s` the standard output and
259
+ # standard error of the child process.
260
+ # * Returns as `status` a `Process::Status` object that represents the exit
261
+ # status of the child process.
262
+ #
263
+ # Returns the array `[stdout_s, stderr_s, status]`:
264
+ #
265
+ # stdout_s, stderr_s, status = Open3.capture3('echo "Foo"')
266
+ # # => ["Foo\n", "", #<Process::Status: pid 2281954 exit 0>]
267
+ #
268
+ # Like Process.spawn, this method has potential security vulnerabilities if
269
+ # called with untrusted input; see [Command
270
+ # Injection](rdoc-ref:command_injection.rdoc@Command+Injection).
271
+ #
272
+ # Unlike Process.spawn, this method waits for the child process to exit before
273
+ # returning, so the caller need not do so.
274
+ #
275
+ # If the first argument is a hash, it becomes leading argument `env` in the call
276
+ # to Open3.popen3; see [Execution
277
+ # Environment](rdoc-ref:Process@Execution+Environment).
278
+ #
279
+ # If the last argument is a hash, it becomes trailing argument `options` in the
280
+ # call to Open3.popen3; see [Execution
281
+ # Options](rdoc-ref:Process@Execution+Options).
282
+ #
283
+ # The hash `options` is given; two options have local effect in method
284
+ # Open3.capture3:
285
+ #
286
+ # * If entry `options[:stdin_data]` exists, the entry is removed and its
287
+ # string value is sent to the command's standard input:
288
+ #
289
+ # Open3.capture3('tee', stdin_data: 'Foo')
290
+ # # => ["Foo", "", #<Process::Status: pid 2319575 exit 0>]
291
+ #
292
+ # * If entry `options[:binmode]` exists, the entry is removed and the internal
293
+ # streams are set to binary mode.
294
+ #
295
+ # The single required argument is one of the following:
296
+ #
297
+ # * `command_line` if it is a string, and if it begins with a shell reserved
298
+ # word or special built-in, or if it contains one or more metacharacters.
299
+ # * `exe_path` otherwise.
300
+ #
301
+ # **Argument `command_line`**
302
+ #
303
+ # String argument `command_line` is a command line to be passed to a shell; it
304
+ # must begin with a shell reserved word, begin with a special built-in, or
305
+ # contain meta characters:
306
+ #
307
+ # Open3.capture3('if true; then echo "Foo"; fi') # Shell reserved word.
308
+ # # => ["Foo\n", "", #<Process::Status: pid 2282025 exit 0>]
309
+ # Open3.capture3('echo') # Built-in.
310
+ # # => ["\n", "", #<Process::Status: pid 2282092 exit 0>]
311
+ # Open3.capture3('date > date.tmp') # Contains meta character.
312
+ # # => ["", "", #<Process::Status: pid 2282110 exit 0>]
313
+ #
314
+ # The command line may also contain arguments and options for the command:
315
+ #
316
+ # Open3.capture3('echo "Foo"')
317
+ # # => ["Foo\n", "", #<Process::Status: pid 2282092 exit 0>]
318
+ #
319
+ # **Argument `exe_path`**
320
+ #
321
+ # Argument `exe_path` is one of the following:
322
+ #
323
+ # * The string path to an executable to be called.
324
+ # * A 2-element array containing the path to an executable and the string to
325
+ # be used as the name of the executing process.
326
+ #
327
+ # Example:
328
+ #
329
+ # Open3.capture3('/usr/bin/date')
330
+ # # => ["Thu Sep 28 05:03:51 PM CDT 2023\n", "", #<Process::Status: pid 2282300 exit 0>]
331
+ #
332
+ # Ruby invokes the executable directly, with no shell and no shell expansion:
333
+ #
334
+ # Open3.capture3('doesnt_exist') # Raises Errno::ENOENT
335
+ #
336
+ # If one or more `args` is given, each is an argument or option to be passed to
337
+ # the executable:
338
+ #
339
+ # Open3.capture3('echo', 'C #')
340
+ # # => ["C #\n", "", #<Process::Status: pid 2282368 exit 0>]
341
+ # Open3.capture3('echo', 'hello', 'world')
342
+ # # => ["hello world\n", "", #<Process::Status: pid 2282372 exit 0>]
343
+ #
344
+ def self?.capture3: (*String, ?stdin_data: String, ?binmode: boolish) -> [String, String, Process::Status]
345
+ | (env, *String, ?stdin_data: String, ?binmode: boolish) -> [String, String, Process::Status]
346
+
347
+ # <!--
348
+ # rdoc-file=lib/open3.rb
349
+ # - Open3.popen2([env, ] command_line, options = {}) -> [stdin, stdout, wait_thread]
350
+ # - Open3.popen2([env, ] exe_path, *args, options = {}) -> [stdin, stdout, wait_thread]
351
+ # - Open3.popen2([env, ] command_line, options = {}) {|stdin, stdout, wait_thread| ... } -> object
352
+ # - Open3.popen2([env, ] exe_path, *args, options = {}) {|stdin, stdout, wait_thread| ... } -> object
353
+ # -->
354
+ # Basically a wrapper for [Process.spawn](rdoc-ref:Process.spawn) that:
355
+ #
356
+ # * Creates a child process, by calling Process.spawn with the given
357
+ # arguments.
358
+ # * Creates streams `stdin` and `stdout`, which are the standard input and
359
+ # standard output streams in the child process.
360
+ # * Creates thread `wait_thread` that waits for the child process to exit; the
361
+ # thread has method `pid`, which returns the process ID of the child
362
+ # process.
363
+ #
364
+ # With no block given, returns the array `[stdin, stdout, wait_thread]`. The
365
+ # caller should close each of the two returned streams.
366
+ #
367
+ # stdin, stdout, wait_thread = Open3.popen2('echo')
368
+ # # => [#<IO:fd 6>, #<IO:fd 7>, #<Process::Waiter:0x00007f58d52dbe98 run>]
369
+ # stdin.close
370
+ # stdout.close
371
+ # wait_thread.pid # => 2263572
372
+ # wait_thread.value # => #<Process::Status: pid 2263572 exit 0>
373
+ #
374
+ # With a block given, calls the block with the three variables (two streams and
375
+ # the wait thread) and returns the block's return value. The caller need not
376
+ # close the streams:
377
+ #
378
+ # Open3.popen2('echo') do |stdin, stdout, wait_thread|
379
+ # p stdin
380
+ # p stdout
381
+ # p wait_thread
382
+ # p wait_thread.pid
383
+ # p wait_thread.value
384
+ # end
385
+ #
386
+ # Output:
387
+ #
388
+ # #<IO:fd 6>
389
+ # #<IO:fd 7>
390
+ # #<Process::Waiter:0x00007f58d59a34b0 sleep>
391
+ # 2263636
392
+ # #<Process::Status: pid 2263636 exit 0>
393
+ #
394
+ # Like Process.spawn, this method has potential security vulnerabilities if
395
+ # called with untrusted input; see [Command
396
+ # Injection](rdoc-ref:command_injection.rdoc@Command+Injection).
397
+ #
398
+ # Unlike Process.spawn, this method waits for the child process to exit before
399
+ # returning, so the caller need not do so.
400
+ #
401
+ # If the first argument is a hash, it becomes leading argument `env` in the call
402
+ # to Process.spawn; see [Execution
403
+ # Environment](rdoc-ref:Process@Execution+Environment).
404
+ #
405
+ # If the last argument is a hash, it becomes trailing argument `options` in the
406
+ # call to Process.spawn; see [Execution
407
+ # Options](rdoc-ref:Process@Execution+Options).
408
+ #
409
+ # The single required argument is one of the following:
410
+ #
411
+ # * `command_line` if it is a string, and if it begins with a shell reserved
412
+ # word or special built-in, or if it contains one or more metacharacters.
413
+ # * `exe_path` otherwise.
414
+ #
415
+ # **Argument `command_line`**
416
+ #
417
+ # String argument `command_line` is a command line to be passed to a shell; it
418
+ # must begin with a shell reserved word, begin with a special built-in, or
419
+ # contain meta characters:
420
+ #
421
+ # Open3.popen2('if true; then echo "Foo"; fi') {|*args| p args } # Shell reserved word.
422
+ # Open3.popen2('echo') {|*args| p args } # Built-in.
423
+ # Open3.popen2('date > date.tmp') {|*args| p args } # Contains meta character.
424
+ #
425
+ # Output (similar for each call above):
426
+ #
427
+ # # => [#<IO:(closed)>, #<IO:(closed)>, #<Process::Waiter:0x00007f7577dfe410 dead>]
428
+ #
429
+ # The command line may also contain arguments and options for the command:
430
+ #
431
+ # Open3.popen2('echo "Foo"') { |i, o, t| o.gets }
432
+ # "Foo\n"
433
+ #
434
+ # **Argument `exe_path`**
435
+ #
436
+ # Argument `exe_path` is one of the following:
437
+ #
438
+ # * The string path to an executable to be called.
439
+ # * A 2-element array containing the path to an executable and the string to
440
+ # be used as the name of the executing process.
441
+ #
442
+ # Example:
443
+ #
444
+ # Open3.popen2('/usr/bin/date') { |i, o, t| o.gets }
445
+ # # => "Thu Sep 28 09:41:06 AM CDT 2023\n"
446
+ #
447
+ # Ruby invokes the executable directly, with no shell and no shell expansion:
448
+ #
449
+ # Open3.popen2('doesnt_exist') { |i, o, t| o.gets } # Raises Errno::ENOENT
450
+ #
451
+ # If one or more `args` is given, each is an argument or option to be passed to
452
+ # the executable:
453
+ #
454
+ # Open3.popen2('echo', 'C #') { |i, o, t| o.gets }
455
+ # # => "C #\n"
456
+ # Open3.popen2('echo', 'hello', 'world') { |i, o, t| o.gets }
457
+ # # => "hello world\n"
458
+ #
459
+ # Related:
460
+ #
461
+ # * Open3.popen2e: Makes the standard input and the merge of the standard
462
+ # output and standard error streams of the child process available as
463
+ # separate streams.
464
+ # * Open3.popen3: Makes the standard input, standard output, and standard
465
+ # error streams of the child process available as separate streams.
466
+ #
467
+ def self?.popen2: (*String, ?unsetenv_others: bool, ?pgroup: true | Integer, ?umask: Integer, ?close_others: bool, ?chdir: String) -> [IO, IO, Process::Waiter]
468
+ | (env, *String, ?unsetenv_others: bool, ?pgroup: true | Integer, ?umask: Integer, ?close_others: bool, ?chdir: String) -> [IO, IO, Process::Waiter]
469
+ | [T] (*String, ?unsetenv_others: bool, ?pgroup: true | Integer, ?umask: Integer, ?close_others: bool, ?chdir: String) { (IO, IO, Process::Waiter) -> T } -> T
470
+ | [T] (env, *String, ?unsetenv_others: bool, ?pgroup: true | Integer, ?umask: Integer, ?close_others: bool, ?chdir: String) { (IO, IO, Process::Waiter) -> T } -> T
471
+
472
+ # <!--
473
+ # rdoc-file=lib/open3.rb
474
+ # - Open3.popen3([env, ] command_line, options = {}) -> [stdin, stdout, stderr, wait_thread]
475
+ # - Open3.popen3([env, ] exe_path, *args, options = {}) -> [stdin, stdout, stderr, wait_thread]
476
+ # - Open3.popen3([env, ] command_line, options = {}) {|stdin, stdout, stderr, wait_thread| ... } -> object
477
+ # - Open3.popen3([env, ] exe_path, *args, options = {}) {|stdin, stdout, stderr, wait_thread| ... } -> object
478
+ # -->
479
+ # Basically a wrapper for [Process.spawn](rdoc-ref:Process.spawn) that:
480
+ #
481
+ # * Creates a child process, by calling Process.spawn with the given
482
+ # arguments.
483
+ # * Creates streams `stdin`, `stdout`, and `stderr`, which are the standard
484
+ # input, standard output, and standard error streams in the child process.
485
+ # * Creates thread `wait_thread` that waits for the child process to exit; the
486
+ # thread has method `pid`, which returns the process ID of the child
487
+ # process.
488
+ #
489
+ # With no block given, returns the array `[stdin, stdout, stderr, wait_thread]`.
490
+ # The caller should close each of the three returned streams.
491
+ #
492
+ # stdin, stdout, stderr, wait_thread = Open3.popen3('echo')
493
+ # # => [#<IO:fd 8>, #<IO:fd 10>, #<IO:fd 12>, #<Process::Waiter:0x00007f58d5428f58 run>]
494
+ # stdin.close
495
+ # stdout.close
496
+ # stderr.close
497
+ # wait_thread.pid # => 2210481
498
+ # wait_thread.value # => #<Process::Status: pid 2210481 exit 0>
499
+ #
500
+ # With a block given, calls the block with the four variables (three streams and
501
+ # the wait thread) and returns the block's return value. The caller need not
502
+ # close the streams:
503
+ #
504
+ # Open3.popen3('echo') do |stdin, stdout, stderr, wait_thread|
505
+ # p stdin
506
+ # p stdout
507
+ # p stderr
508
+ # p wait_thread
509
+ # p wait_thread.pid
510
+ # p wait_thread.value
511
+ # end
512
+ #
513
+ # Output:
514
+ #
515
+ # #<IO:fd 6>
516
+ # #<IO:fd 7>
517
+ # #<IO:fd 9>
518
+ # #<Process::Waiter:0x00007f58d53606e8 sleep>
519
+ # 2211047
520
+ # #<Process::Status: pid 2211047 exit 0>
521
+ #
522
+ # Like Process.spawn, this method has potential security vulnerabilities if
523
+ # called with untrusted input; see [Command
524
+ # Injection](rdoc-ref:command_injection.rdoc@Command+Injection).
525
+ #
526
+ # Unlike Process.spawn, this method waits for the child process to exit before
527
+ # returning, so the caller need not do so.
528
+ #
529
+ # If the first argument is a hash, it becomes leading argument `env` in the call
530
+ # to Process.spawn; see [Execution
531
+ # Environment](rdoc-ref:Process@Execution+Environment).
532
+ #
533
+ # If the last argument is a hash, it becomes trailing argument `options` in the
534
+ # call to Process.spawn; see [Execution
535
+ # Options](rdoc-ref:Process@Execution+Options).
536
+ #
537
+ # The single required argument is one of the following:
538
+ #
539
+ # * `command_line` if it is a string, and if it begins with a shell reserved
540
+ # word or special built-in, or if it contains one or more metacharacters.
541
+ # * `exe_path` otherwise.
542
+ #
543
+ # **Argument `command_line`**
544
+ #
545
+ # String argument `command_line` is a command line to be passed to a shell; it
546
+ # must begin with a shell reserved word, begin with a special built-in, or
547
+ # contain meta characters:
548
+ #
549
+ # Open3.popen3('if true; then echo "Foo"; fi') {|*args| p args } # Shell reserved word.
550
+ # Open3.popen3('echo') {|*args| p args } # Built-in.
551
+ # Open3.popen3('date > date.tmp') {|*args| p args } # Contains meta character.
552
+ #
553
+ # Output (similar for each call above):
554
+ #
555
+ # [#<IO:(closed)>, #<IO:(closed)>, #<IO:(closed)>, #<Process::Waiter:0x00007f58d52f28c8 dead>]
556
+ #
557
+ # The command line may also contain arguments and options for the command:
558
+ #
559
+ # Open3.popen3('echo "Foo"') { |i, o, e, t| o.gets }
560
+ # "Foo\n"
561
+ #
562
+ # **Argument `exe_path`**
563
+ #
564
+ # Argument `exe_path` is one of the following:
565
+ #
566
+ # * The string path to an executable to be called.
567
+ # * A 2-element array containing the path to an executable and the string to
568
+ # be used as the name of the executing process.
569
+ #
570
+ # Example:
571
+ #
572
+ # Open3.popen3('/usr/bin/date') { |i, o, e, t| o.gets }
573
+ # # => "Wed Sep 27 02:56:44 PM CDT 2023\n"
574
+ #
575
+ # Ruby invokes the executable directly, with no shell and no shell expansion:
576
+ #
577
+ # Open3.popen3('doesnt_exist') { |i, o, e, t| o.gets } # Raises Errno::ENOENT
578
+ #
579
+ # If one or more `args` is given, each is an argument or option to be passed to
580
+ # the executable:
581
+ #
582
+ # Open3.popen3('echo', 'C #') { |i, o, e, t| o.gets }
583
+ # # => "C #\n"
584
+ # Open3.popen3('echo', 'hello', 'world') { |i, o, e, t| o.gets }
585
+ # # => "hello world\n"
586
+ #
587
+ # Take care to avoid deadlocks. Output streams `stdout` and `stderr` have
588
+ # fixed-size buffers, so reading extensively from one but not the other can
589
+ # cause a deadlock when the unread buffer fills. To avoid that, `stdout` and
590
+ # `stderr` should be read simultaneously (using threads or IO.select).
591
+ #
592
+ # Related:
593
+ #
594
+ # * Open3.popen2: Makes the standard input and standard output streams of the
595
+ # child process available as separate streams, with no access to the
596
+ # standard error stream.
597
+ # * Open3.popen2e: Makes the standard input and the merge of the standard
598
+ # output and standard error streams of the child process available as
599
+ # separate streams.
600
+ #
601
+ def self?.popen3: (*String, ?unsetenv_others: bool, ?pgroup: true | Integer, ?umask: Integer, ?close_others: bool, ?chdir: String) -> [IO, IO, IO, Process::Waiter]
602
+ | (env, *String, ?unsetenv_others: bool, ?pgroup: true | Integer, ?umask: Integer, ?close_others: bool, ?chdir: String) -> [IO, IO, IO, Process::Waiter]
603
+ | [T] (*String, ?unsetenv_others: bool, ?pgroup: true | Integer, ?umask: Integer, ?close_others: bool, ?chdir: String) { (IO, IO, IO, Process::Waiter) -> T } -> T
604
+ | [T] (env, *String, ?unsetenv_others: bool, ?pgroup: true | Integer, ?umask: Integer, ?close_others: bool, ?chdir: String) { (IO, IO, IO, Process::Waiter) -> T } -> T
147
605
  end