rbs 0.12.2 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +8 -4
  3. data/.gitignore +0 -1
  4. data/CHANGELOG.md +32 -0
  5. data/Gemfile +4 -0
  6. data/README.md +8 -2
  7. data/Rakefile +9 -2
  8. data/Steepfile +1 -1
  9. data/bin/annotate-with-rdoc +1 -1
  10. data/bin/setup +0 -2
  11. data/bin/test_runner.rb +15 -1
  12. data/{stdlib/builtin → core}/array.rbs +124 -120
  13. data/{stdlib/builtin → core}/basic_object.rbs +54 -54
  14. data/{stdlib/builtin → core}/binding.rbs +42 -42
  15. data/core/builtin.rbs +70 -0
  16. data/{stdlib/builtin → core}/class.rbs +33 -33
  17. data/{stdlib/builtin → core}/comparable.rbs +0 -0
  18. data/{stdlib/builtin → core}/complex.rbs +90 -90
  19. data/{stdlib/builtin → core}/constants.rbs +0 -0
  20. data/{stdlib/builtin → core}/data.rbs +0 -0
  21. data/{stdlib/builtin → core}/deprecated.rbs +0 -0
  22. data/{stdlib/builtin → core}/dir.rbs +0 -0
  23. data/{stdlib/builtin → core}/encoding.rbs +33 -33
  24. data/{stdlib/builtin → core}/enumerable.rbs +58 -52
  25. data/{stdlib/builtin → core}/enumerator.rbs +35 -35
  26. data/{stdlib/builtin → core}/errno.rbs +0 -0
  27. data/{stdlib/builtin → core}/errors.rbs +2 -2
  28. data/{stdlib/builtin → core}/exception.rbs +50 -50
  29. data/{stdlib/builtin → core}/false_class.rbs +6 -6
  30. data/{stdlib/builtin → core}/fiber.rbs +14 -14
  31. data/{stdlib/builtin → core}/fiber_error.rbs +1 -1
  32. data/{stdlib/builtin → core}/file.rbs +0 -0
  33. data/{stdlib/builtin → core}/file_test.rbs +0 -0
  34. data/{stdlib/builtin → core}/float.rbs +161 -161
  35. data/{stdlib/builtin → core}/gc.rbs +3 -3
  36. data/{stdlib/builtin → core}/hash.rbs +7 -7
  37. data/{stdlib/builtin → core}/integer.rbs +0 -0
  38. data/{stdlib/builtin → core}/io.rbs +88 -88
  39. data/{stdlib/builtin → core}/kernel.rbs +71 -153
  40. data/{stdlib/builtin → core}/marshal.rbs +0 -0
  41. data/{stdlib/builtin → core}/match_data.rbs +1 -1
  42. data/{stdlib/builtin → core}/math.rbs +0 -0
  43. data/{stdlib/builtin → core}/method.rbs +19 -19
  44. data/{stdlib/builtin → core}/module.rbs +13 -13
  45. data/{stdlib/builtin → core}/nil_class.rbs +20 -20
  46. data/{stdlib/builtin → core}/numeric.rbs +101 -101
  47. data/{stdlib/builtin → core}/object.rbs +173 -173
  48. data/{stdlib/builtin → core}/proc.rbs +91 -91
  49. data/{stdlib/builtin → core}/process.rbs +0 -0
  50. data/{stdlib/builtin → core}/random.rbs +1 -1
  51. data/{stdlib/builtin → core}/range.rbs +3 -5
  52. data/{stdlib/builtin → core}/rational.rbs +83 -83
  53. data/{stdlib/builtin → core}/rb_config.rbs +0 -0
  54. data/{stdlib/builtin → core}/regexp.rbs +0 -0
  55. data/{stdlib/builtin → core}/ruby_vm.rbs +0 -0
  56. data/{stdlib/builtin → core}/signal.rbs +7 -7
  57. data/{stdlib/builtin → core}/string.rbs +10 -10
  58. data/{stdlib/builtin → core}/string_io.rbs +8 -8
  59. data/{stdlib/builtin → core}/struct.rbs +1 -1
  60. data/{stdlib/builtin → core}/symbol.rbs +1 -1
  61. data/{stdlib/builtin → core}/thread.rbs +189 -189
  62. data/{stdlib/builtin → core}/thread_group.rbs +2 -2
  63. data/{stdlib/builtin → core}/time.rbs +0 -0
  64. data/{stdlib/builtin → core}/trace_point.rbs +0 -0
  65. data/{stdlib/builtin → core}/true_class.rbs +10 -10
  66. data/{stdlib/builtin → core}/unbound_method.rbs +0 -0
  67. data/{stdlib/builtin → core}/warning.rbs +1 -1
  68. data/docs/CONTRIBUTING.md +1 -0
  69. data/docs/repo.md +125 -0
  70. data/docs/syntax.md +50 -6
  71. data/goodcheck.yml +22 -5
  72. data/lib/rbs.rb +1 -0
  73. data/lib/rbs/ast/comment.rb +1 -1
  74. data/lib/rbs/cli.rb +117 -107
  75. data/lib/rbs/constant.rb +1 -1
  76. data/lib/rbs/constant_table.rb +9 -8
  77. data/lib/rbs/definition_builder.rb +6 -7
  78. data/lib/rbs/environment.rb +5 -1
  79. data/lib/rbs/environment_loader.rb +79 -105
  80. data/lib/rbs/namespace.rb +1 -1
  81. data/lib/rbs/parser.rb +3148 -0
  82. data/lib/rbs/parser.y +10 -3
  83. data/lib/rbs/prototype/rb.rb +38 -6
  84. data/lib/rbs/prototype/runtime.rb +17 -7
  85. data/lib/rbs/repository.rb +121 -0
  86. data/lib/rbs/test/hook.rb +2 -0
  87. data/lib/rbs/test/setup.rb +5 -3
  88. data/lib/rbs/test/setup_helper.rb +4 -4
  89. data/lib/rbs/test/tester.rb +4 -1
  90. data/lib/rbs/test/type_check.rb +12 -6
  91. data/lib/rbs/type_name.rb +3 -2
  92. data/lib/rbs/variance_calculator.rb +2 -2
  93. data/lib/rbs/vendorer.rb +38 -16
  94. data/lib/rbs/version.rb +1 -1
  95. data/lib/rbs/writer.rb +25 -15
  96. data/sig/cli.rbs +58 -0
  97. data/sig/constant.rbs +21 -0
  98. data/sig/constant_table.rbs +30 -0
  99. data/sig/declarations.rbs +2 -2
  100. data/sig/definition.rbs +2 -2
  101. data/sig/definition_builder.rbs +6 -5
  102. data/sig/environment_loader.rbs +100 -0
  103. data/sig/members.rbs +2 -2
  104. data/sig/method_types.rbs +1 -1
  105. data/sig/namespace.rbs +4 -4
  106. data/sig/parser.rbs +25 -0
  107. data/sig/polyfill.rbs +42 -0
  108. data/sig/rbs.rbs +8 -0
  109. data/sig/repository.rbs +79 -0
  110. data/sig/substitution.rbs +3 -3
  111. data/sig/typename.rbs +1 -1
  112. data/sig/types.rbs +1 -1
  113. data/sig/vendorer.rbs +44 -0
  114. data/sig/version.rbs +3 -0
  115. data/sig/writer.rbs +40 -0
  116. data/stdlib/abbrev/{abbrev.rbs → 0/abbrev.rbs} +0 -0
  117. data/stdlib/base64/{base64.rbs → 0/base64.rbs} +1 -1
  118. data/stdlib/benchmark/{benchmark.rbs → 0/benchmark.rbs} +2 -2
  119. data/stdlib/{bigdecimal/math → bigdecimal-math/0}/big_math.rbs +0 -0
  120. data/stdlib/bigdecimal/{big_decimal.rbs → 0/big_decimal.rbs} +0 -0
  121. data/stdlib/coverage/{coverage.rbs → 0/coverage.rbs} +2 -2
  122. data/stdlib/csv/{csv.rbs → 0/csv.rbs} +1 -1
  123. data/stdlib/date/{date.rbs → 0/date.rbs} +4 -4
  124. data/stdlib/date/{date_time.rbs → 0/date_time.rbs} +1 -1
  125. data/stdlib/dbm/0/dbm.rbs +277 -0
  126. data/stdlib/erb/{erb.rbs → 0/erb.rbs} +0 -0
  127. data/stdlib/fiber/{fiber.rbs → 0/fiber.rbs} +0 -0
  128. data/stdlib/find/{find.rbs → 0/find.rbs} +12 -12
  129. data/stdlib/forwardable/{forwardable.rbs → 0/forwardable.rbs} +0 -0
  130. data/stdlib/ipaddr/{ipaddr.rbs → 0/ipaddr.rbs} +0 -0
  131. data/stdlib/json/{json.rbs → 0/json.rbs} +0 -0
  132. data/stdlib/logger/{formatter.rbs → 0/formatter.rbs} +0 -0
  133. data/stdlib/logger/{log_device.rbs → 0/log_device.rbs} +1 -1
  134. data/stdlib/logger/{logger.rbs → 0/logger.rbs} +1 -1
  135. data/stdlib/logger/{period.rbs → 0/period.rbs} +0 -0
  136. data/stdlib/logger/{severity.rbs → 0/severity.rbs} +0 -0
  137. data/stdlib/mutex_m/{mutex_m.rbs → 0/mutex_m.rbs} +0 -0
  138. data/stdlib/pathname/{pathname.rbs → 0/pathname.rbs} +41 -39
  139. data/stdlib/prime/{integer-extension.rbs → 0/integer-extension.rbs} +0 -0
  140. data/stdlib/prime/{prime.rbs → 0/prime.rbs} +0 -0
  141. data/stdlib/pstore/0/pstore.rbs +287 -0
  142. data/stdlib/pty/{pty.rbs → 0/pty.rbs} +1 -1
  143. data/stdlib/securerandom/{securerandom.rbs → 0/securerandom.rbs} +0 -0
  144. data/stdlib/set/{set.rbs → 0/set.rbs} +0 -0
  145. data/stdlib/tmpdir/{tmpdir.rbs → 0/tmpdir.rbs} +12 -12
  146. data/stdlib/uri/{file.rbs → 0/file.rbs} +0 -0
  147. data/stdlib/uri/{generic.rbs → 0/generic.rbs} +2 -2
  148. data/stdlib/uri/0/http.rbs +158 -0
  149. data/stdlib/uri/0/https.rbs +108 -0
  150. data/stdlib/uri/0/ldap.rbs +224 -0
  151. data/stdlib/uri/0/ldaps.rbs +108 -0
  152. data/stdlib/zlib/{zlib.rbs → 0/zlib.rbs} +0 -0
  153. data/steep/Gemfile.lock +13 -17
  154. metadata +105 -89
  155. data/stdlib/builtin/builtin.rbs +0 -42
@@ -1,16 +1,18 @@
1
1
  # The [Kernel](Kernel) module is included by class
2
2
  # [Object](https://ruby-doc.org/core-2.6.3/Object.html), so its methods
3
3
  # are available in every Ruby object.
4
- #
4
+ #
5
5
  # The [Kernel](Kernel) instance methods are documented
6
6
  # in class [Object](https://ruby-doc.org/core-2.6.3/Object.html) while the
7
7
  # module methods are documented here. These methods are called without a
8
8
  # receiver and thus can be called in functional form:
9
- #
9
+ #
10
10
  # ```ruby
11
11
  # sprintf "%.1f", 1.234 #=> "1.2"
12
12
  # ```
13
13
  module Kernel
14
+ private
15
+
14
16
  def caller: (?Integer start_or_range, ?Integer length) -> ::Array[String]?
15
17
  | (?::Range[Integer] start_or_range) -> ::Array[String]?
16
18
  | () -> ::Array[String]
@@ -22,13 +24,13 @@ module Kernel
22
24
  | () { (Object tag) -> untyped } -> untyped
23
25
 
24
26
  # In a perfect world this should be:
25
- #
27
+ #
26
28
  # returns(T.class_of(T.self_type))
27
- #
29
+ #
28
30
  # but that doesn't work (yet). Even making it:
29
- #
31
+ #
30
32
  # returns(Class)
31
- #
33
+ #
32
34
  # is very surprising since users expect their methods to be present.
33
35
  # So we settle for untyped.
34
36
  def `class`: () -> untyped
@@ -40,7 +42,7 @@ module Kernel
40
42
 
41
43
  # Returns `true` if `yield` would execute a block in the current context.
42
44
  # The `iterator?` form is mildly deprecated.
43
- #
45
+ #
44
46
  # ```ruby
45
47
  # def try
46
48
  # if block_given?
@@ -57,7 +59,7 @@ module Kernel
57
59
  alias block_given? iterator?
58
60
 
59
61
  # Returns the names of the current local variables.
60
- #
62
+ #
61
63
  # ```ruby
62
64
  # fred = 1
63
65
  # for i in 1..10
@@ -69,28 +71,6 @@ module Kernel
69
71
 
70
72
  def srand: (?Numeric number) -> Numeric
71
73
 
72
- def !~: (untyped other) -> bool
73
-
74
- def <=>: (untyped other) -> Integer?
75
-
76
- def ===: (untyped other) -> bool
77
-
78
- def =~: (untyped other) -> NilClass
79
-
80
- def clone: (?freeze: (TrueClass | FalseClass)) -> self
81
-
82
- def display: (?IO port) -> NilClass
83
-
84
- def dup: () -> self
85
-
86
- def enum_for: (Symbol method, *untyped args) -> ::Enumerator[untyped, untyped]
87
- | (Symbol method, *untyped args) { (*untyped args) -> (Integer|Float|nil) } -> ::Enumerator[untyped, untyped]
88
- alias to_enum enum_for
89
-
90
- def eql?: (untyped other) -> bool
91
-
92
- def `extend`: (*Module mod) -> self
93
-
94
74
  # Creates a subprocess. If a block is specified, that block is run in the
95
75
  # subprocess, and the subprocess terminates with a status of zero.
96
76
  # Otherwise, the `fork` call returns twice, once in the parent, returning
@@ -100,93 +80,31 @@ module Kernel
100
80
  # collect the termination statuses of its children or use `Process.detach`
101
81
  # to register disinterest in their status; otherwise, the operating system
102
82
  # may accumulate zombie processes.
103
- #
83
+ #
104
84
  # The thread calling fork is the only thread in the created child process.
105
85
  # fork doesn’t copy other threads.
106
- #
86
+ #
107
87
  # If fork is not usable, Process.respond\_to?(:fork) returns false.
108
- #
88
+ #
109
89
  # Note that fork(2) is not available on some platforms like Windows and
110
90
  # NetBSD 4. Therefore you should use spawn() instead of fork().
111
91
  def fork: () -> Integer?
112
92
  | () { () -> untyped } -> Integer?
113
93
 
114
- def freeze: () -> self
115
-
116
- def frozen?: () -> bool
117
-
118
- def hash: () -> Integer
119
-
120
94
  def initialize_copy: (self object) -> self
121
95
 
122
- def inspect: () -> String
123
-
124
- def instance_of?: (Class arg0) -> bool
125
-
126
- def instance_variable_defined?: (Symbol | String arg0) -> bool
127
-
128
- def instance_variable_get: (Symbol | String arg0) -> untyped
129
-
130
- def instance_variable_set: [T] (Symbol | String arg0, T arg1) -> T
131
-
132
- def instance_variables: () -> ::Array[Symbol]
133
-
134
- def is_a?: (Class | Module arg0) -> bool
135
- alias kind_of? is_a?
136
-
137
- def method: (Symbol | String arg0) -> Method
138
-
139
- def methods: (?bool regular) -> ::Array[Symbol]
140
-
141
- def `nil?`: () -> FalseClass
142
-
143
- def private_methods: (?bool all) -> ::Array[Symbol]
144
-
145
- def protected_methods: (?bool all) -> ::Array[Symbol]
146
-
147
- def public_method: (Symbol | String arg0) -> Method
148
-
149
- def public_methods: (?bool all) -> ::Array[Symbol]
150
-
151
- def `public_send`: (Symbol | String arg0, *untyped args) -> untyped
152
- | (Symbol | String arg0, *untyped args) { (*untyped) -> untyped } -> untyped
153
-
154
- def remove_instance_variable: (Symbol | String arg0) -> untyped
155
-
156
- def `send`: (String | Symbol arg0, *untyped arg1) -> untyped
157
- | (String | Symbol arg0, *untyped arg1) { (*untyped) -> untyped } -> untyped
158
-
159
- def `singleton_class`: () -> Class
160
-
161
- def singleton_method: (Symbol | String arg0) -> Method
162
-
163
- def singleton_methods: (?bool all) -> ::Array[Symbol]
164
-
165
- def taint: () -> self
166
- alias untrust taint
167
-
168
- def tainted?: () -> bool
169
- alias untrusted? tainted?
170
-
171
- def tap: () { (untyped x) -> void } -> self
172
-
173
- def to_s: () -> String
174
-
175
- def untaint: () -> self
176
- alias trust untaint
177
-
178
96
  # Returns `arg` as an [Array](https://ruby-doc.org/core-2.6.3/Array.html)
179
97
  # .
180
- #
98
+ #
181
99
  # First tries to call `to_ary` on `arg`, then `to_a` . If `arg` does not
182
100
  # respond to `to_ary` or `to_a`, returns an
183
101
  # [Array](https://ruby-doc.org/core-2.6.3/Array.html) of length 1
184
102
  # containing `arg` .
185
- #
103
+ #
186
104
  # If `to_ary` or `to_a` returns something other than an
187
105
  # [Array](https://ruby-doc.org/core-2.6.3/Array.html), raises a
188
106
  # `TypeError` .
189
- #
107
+ #
190
108
  # ```ruby
191
109
  # Array(["a", "b"]) #=> ["a", "b"]
192
110
  # Array(1..5) #=> [1, 2, 3, 4, 5]
@@ -243,7 +161,7 @@ module Kernel
243
161
  # at the point of call. This object can be used when calling `eval` to
244
162
  # execute the evaluated command in this environment. See also the
245
163
  # description of class `Binding` .
246
- #
164
+ #
247
165
  # ```ruby
248
166
  # def get_binding(param)
249
167
  # binding
@@ -258,7 +176,7 @@ module Kernel
258
176
  # to return a status code to the invoking environment. `true` and `FALSE`
259
177
  # of *status* means success and failure respectively. The interpretation
260
178
  # of other integer values are system dependent.
261
- #
179
+ #
262
180
  # ```ruby
263
181
  # begin
264
182
  # exit
@@ -268,25 +186,25 @@ module Kernel
268
186
  # end
269
187
  # puts "after begin block"
270
188
  # ```
271
- #
189
+ #
272
190
  # *produces:*
273
- #
191
+ #
274
192
  # rescued a SystemExit exception
275
193
  # after begin block
276
- #
194
+ #
277
195
  # Just prior to termination, Ruby executes any `at_exit` functions (see
278
196
  # Kernel::at\_exit) and runs any object finalizers (see
279
197
  # [ObjectSpace.define\_finalizer](https://ruby-doc.org/core-2.6.3/ObjectSpace.html#method-c-define_finalizer)
280
198
  # ).
281
- #
199
+ #
282
200
  # ```ruby
283
201
  # at_exit { puts "at_exit function" }
284
202
  # ObjectSpace.define_finalizer("string", proc { puts "in finalizer" })
285
203
  # exit
286
204
  # ```
287
- #
205
+ #
288
206
  # *produces:*
289
- #
207
+ #
290
208
  # at_exit function
291
209
  # in finalizer
292
210
  def exit: () -> bot
@@ -323,18 +241,18 @@ module Kernel
323
241
  def gets: (?String arg0, ?Integer arg1) -> String?
324
242
 
325
243
  # Returns an array of the names of global variables.
326
- #
244
+ #
327
245
  # ```ruby
328
246
  # global_variables.grep /std/ #=> [:$stdin, :$stdout, :$stderr]
329
247
  # ```
330
248
  def global_variables: () -> ::Array[Symbol]
331
249
 
332
- def load: (String filename, ?bool arg0) -> bool
250
+ def load: (String filename, ?boolish) -> bool
333
251
 
334
252
  # Repeatedly executes the block.
335
- #
253
+ #
336
254
  # If no block is given, an enumerator is returned instead.
337
- #
255
+ #
338
256
  # ```ruby
339
257
  # loop do
340
258
  # print "Input: "
@@ -343,18 +261,18 @@ module Kernel
343
261
  # # ...
344
262
  # end
345
263
  # ```
346
- #
264
+ #
347
265
  # [StopIteration](https://ruby-doc.org/core-2.6.3/StopIteration.html)
348
266
  # raised in the block breaks the loop. In this case, loop returns the
349
267
  # "result" value stored in the exception.
350
- #
268
+ #
351
269
  # ```ruby
352
270
  # enum = Enumerator.new { |y|
353
271
  # y << "one"
354
272
  # y << "two"
355
273
  # :ok
356
274
  # }
357
- #
275
+ #
358
276
  # result = loop {
359
277
  # puts enum.next
360
278
  # } #=> :ok
@@ -370,16 +288,16 @@ module Kernel
370
288
  # the output record separator ( `$\` ) is not `nil`, it will be appended
371
289
  # to the output. If no arguments are given, prints `$_` . Objects that
372
290
  # aren’t strings will be converted by calling their `to_s` method.
373
- #
291
+ #
374
292
  # ```ruby
375
293
  # print "cat", [1,2,3], 99, "\n"
376
294
  # $, = ", "
377
295
  # $\ = "\n"
378
296
  # print "cat", [1,2,3], 99
379
297
  # ```
380
- #
298
+ #
381
299
  # *produces:*
382
- #
300
+ #
383
301
  # cat12399
384
302
  # cat, 1, 2, 3, 99
385
303
  def print: (*Kernel args) -> nil
@@ -406,35 +324,35 @@ module Kernel
406
324
  # If called without an argument, or if `max.to_i.abs == 0`, rand returns
407
325
  # a pseudo-random floating point number between 0.0 and 1.0, including 0.0
408
326
  # and excluding 1.0.
409
- #
327
+ #
410
328
  # ```ruby
411
329
  # rand #=> 0.2725926052826416
412
330
  # ```
413
- #
331
+ #
414
332
  # When `max.abs` is greater than or equal to 1, `rand` returns a
415
333
  # pseudo-random integer greater than or equal to 0 and less than
416
334
  # `max.to_i.abs` .
417
- #
335
+ #
418
336
  # ```ruby
419
337
  # rand(100) #=> 12
420
338
  # ```
421
- #
339
+ #
422
340
  # When `max` is a [Range](https://ruby-doc.org/core-2.6.3/Range.html),
423
341
  # `rand` returns a random number where range.member?(number) == true.
424
- #
342
+ #
425
343
  # Negative or floating point values for `max` are allowed, but may give
426
344
  # surprising results.
427
- #
345
+ #
428
346
  # ```ruby
429
347
  # rand(-100) # => 87
430
348
  # rand(-0.5) # => 0.8130921818028143
431
349
  # rand(1.9) # equivalent to rand(1), which is always 0
432
350
  # ```
433
- #
351
+ #
434
352
  # [\#srand](Kernel.downloaded.ruby_doc#method-i-srand) may be used to
435
353
  # ensure that sequences of random numbers are reproducible between
436
354
  # different runs of a program.
437
- #
355
+ #
438
356
  # See also
439
357
  # [Random\#rand](https://ruby-doc.org/core-2.6.3/Random.html#method-i-rand)
440
358
  # .
@@ -466,109 +384,109 @@ module Kernel
466
384
 
467
385
  # Replaces the current process by running the given external *command* ,
468
386
  # which can take one of the following forms:
469
- #
387
+ #
470
388
  # - `exec(commandline)`
471
389
  # command line string which is passed to the standard shell
472
- #
390
+ #
473
391
  # - `exec(cmdname, arg1, ...)`
474
392
  # command name and one or more arguments (no shell)
475
- #
393
+ #
476
394
  # - `exec([cmdname, argv0], arg1, ...)`
477
395
  # command name, [argv](https://ruby-doc.org/core-2.6.3/0) and zero or
478
396
  # more arguments (no shell)
479
- #
397
+ #
480
398
  # In the first form, the string is taken as a command line that is subject
481
399
  # to shell expansion before being executed.
482
- #
400
+ #
483
401
  # The standard shell always means `"/bin/sh"` on Unix-like systems, same
484
402
  # as `ENV["RUBYSHELL"]` (or `ENV["COMSPEC"]` on Windows NT series), and
485
403
  # similar.
486
- #
404
+ #
487
405
  # If the string from the first form ( `exec("command")` ) follows these
488
406
  # simple rules:
489
- #
407
+ #
490
408
  # - no meta characters
491
- #
409
+ #
492
410
  # - no shell reserved word and no special built-in
493
- #
411
+ #
494
412
  # - Ruby invokes the command directly without shell
495
- #
413
+ #
496
414
  # You can force shell invocation by adding “;” to the string (because “;”
497
415
  # is a meta character).
498
- #
416
+ #
499
417
  # Note that this behavior is observable by pid obtained (return value of
500
418
  # spawn() and
501
419
  # [IO\#pid](https://ruby-doc.org/core-2.6.3/IO.html#method-i-pid) for
502
420
  # [IO.popen](https://ruby-doc.org/core-2.6.3/IO.html#method-c-popen) ) is
503
421
  # the pid of the invoked command, not shell.
504
- #
422
+ #
505
423
  # In the second form ( `exec("command1", "arg1", ...)` ), the first is
506
424
  # taken as a command name and the rest are passed as parameters to command
507
425
  # with no shell expansion.
508
- #
426
+ #
509
427
  # In the third form ( `exec(["command", "argv0"], "arg1", ...)` ),
510
428
  # starting a two-element array at the beginning of the command, the first
511
429
  # element is the command to be executed, and the second argument is used
512
430
  # as the `argv[0]` value, which may show up in process listings.
513
- #
431
+ #
514
432
  # In order to execute the command, one of the `exec(2)` system calls are
515
433
  # used, so the running command may inherit some of the environment of the
516
434
  # original program (including open file descriptors).
517
- #
435
+ #
518
436
  # This behavior is modified by the given `env` and `options` parameters.
519
437
  # See ::spawn for details.
520
- #
438
+ #
521
439
  # If the command fails to execute (typically `Errno::ENOENT` when it was
522
440
  # not found) a
523
441
  # [SystemCallError](https://ruby-doc.org/core-2.6.3/SystemCallError.html)
524
442
  # exception is raised.
525
- #
443
+ #
526
444
  # This method modifies process attributes according to given `options`
527
445
  # before `exec(2)` system call. See ::spawn for more details about the
528
446
  # given `options` .
529
- #
447
+ #
530
448
  # The modified attributes may be retained when `exec(2)` system call
531
449
  # fails.
532
- #
450
+ #
533
451
  # For example, hard resource limits are not restorable.
534
- #
452
+ #
535
453
  # Consider to create a child process using ::spawn or
536
454
  # [\#system](Kernel.downloaded.ruby_doc#method-i-system) if this is not
537
455
  # acceptable.
538
- #
456
+ #
539
457
  # ```ruby
540
458
  # exec "echo *" # echoes list of files in current directory
541
459
  # # never get here
542
- #
460
+ #
543
461
  # exec "echo", "*" # echoes an asterisk
544
462
  # # never get here
545
463
  # ```
546
464
  def exec: (*String args) -> bot
547
465
 
548
466
  # Executes *command…* in a subshell. *command…* is one of following forms.
549
- #
467
+ #
550
468
  # commandline : command line string which is passed to the standard shell
551
469
  # cmdname, arg1, ... : command name and one or more arguments (no shell)
552
470
  # [cmdname, argv0], arg1, ... : command name, argv[0] and zero or more arguments (no shell)
553
- #
471
+ #
554
472
  # system returns `true` if the command gives zero exit status, `false` for
555
473
  # non zero exit status. Returns `nil` if command execution fails. An error
556
474
  # status is available in `$?` . The arguments are processed in the same
557
475
  # way as for `Kernel.spawn` .
558
- #
476
+ #
559
477
  # The hash arguments, env and options, are same as `exec` and `spawn` .
560
478
  # See `Kernel.spawn` for details.
561
- #
479
+ #
562
480
  # ```ruby
563
481
  # system("echo *")
564
482
  # system("echo", "*")
565
483
  # ```
566
- #
484
+ #
567
485
  # *produces:*
568
- #
486
+ #
569
487
  # config.h main.rb
570
488
  # *
571
- #
489
+ #
572
490
  # See `Kernel.exec` for the standard shell.
573
491
  def system: (*String args) -> (NilClass | FalseClass | TrueClass)
574
492
  end