irb 1.10.1 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/irb.rb CHANGED
@@ -22,277 +22,836 @@ require_relative "irb/easter-egg"
22
22
  require_relative "irb/debug"
23
23
  require_relative "irb/pager"
24
24
 
25
- # IRB stands for "interactive Ruby" and is a tool to interactively execute Ruby
26
- # expressions read from the standard input.
27
- #
28
- # The +irb+ command from your shell will start the interpreter.
29
- #
30
- # == Usage
31
- #
32
- # Use of irb is easy if you know Ruby.
33
- #
34
- # When executing irb, prompts are displayed as follows. Then, enter the Ruby
35
- # expression. An input is executed when it is syntactically complete.
36
- #
37
- # $ irb
38
- # irb(main):001:0> 1+2
39
- # #=> 3
40
- # irb(main):002:0> class Foo
41
- # irb(main):003:1> def foo
42
- # irb(main):004:2> print 1
43
- # irb(main):005:2> end
44
- # irb(main):006:1> end
45
- # #=> nil
46
- #
47
- # The singleline editor module or multiline editor module can be used with irb.
48
- # Use of multiline editor is default if it's installed.
49
- #
50
- # == Command line options
51
- #
52
- # :include: ./irb/lc/help-message
53
- #
54
- # == Commands
55
- #
56
- # The following commands are available on IRB.
57
- #
58
- # * cwws
59
- # * Show the current workspace.
60
- # * cb, cws, chws
61
- # * Change the current workspace to an object.
62
- # * bindings, workspaces
63
- # * Show workspaces.
64
- # * pushb, pushws
65
- # * Push an object to the workspace stack.
66
- # * popb, popws
67
- # * Pop a workspace from the workspace stack.
68
- # * load
69
- # * Load a Ruby file.
70
- # * require
71
- # * Require a Ruby file.
72
- # * source
73
- # * Loads a given file in the current session.
74
- # * irb
75
- # * Start a child IRB.
76
- # * jobs
77
- # * List of current sessions.
78
- # * fg
79
- # * Switches to the session of the given number.
80
- # * kill
81
- # * Kills the session with the given number.
82
- # * help
83
- # * Enter the mode to look up RI documents.
84
- # * irb_info
85
- # * Show information about IRB.
86
- # * ls
87
- # * Show methods, constants, and variables.
88
- # -g [query] or -G [query] allows you to filter out the output.
89
- # * measure
90
- # * measure enables the mode to measure processing time. measure :off disables it.
91
- # * $, show_source
92
- # * Show the source code of a given method or constant.
93
- # * @, whereami
94
- # * Show the source code around binding.irb again.
95
- # * debug
96
- # * Start the debugger of debug.gem.
97
- # * break, delete, next, step, continue, finish, backtrace, info, catch
98
- # * Start the debugger of debug.gem and run the command on it.
99
- #
100
- # == Configuration
101
- #
102
- # IRB reads a personal initialization file when it's invoked.
103
- # IRB searches a file in the following order and loads the first one found.
104
- #
105
- # * <tt>$IRBRC</tt> (if <tt>$IRBRC</tt> is set)
106
- # * <tt>$XDG_CONFIG_HOME/irb/irbrc</tt> (if <tt>$XDG_CONFIG_HOME</tt> is set)
107
- # * <tt>~/.irbrc</tt>
108
- # * +.config/irb/irbrc+
109
- # * +.irbrc+
110
- # * +irb.rc+
111
- # * +_irbrc+
112
- # * <code>$irbrc</code>
113
- #
114
- # The following are alternatives to the command line options. To use them type
115
- # as follows in an +irb+ session:
116
- #
117
- # IRB.conf[:IRB_NAME]="irb"
118
- # IRB.conf[:INSPECT_MODE]=nil
119
- # IRB.conf[:IRB_RC] = nil
120
- # IRB.conf[:BACK_TRACE_LIMIT]=16
121
- # IRB.conf[:USE_LOADER] = false
122
- # IRB.conf[:USE_MULTILINE] = nil
123
- # IRB.conf[:USE_SINGLELINE] = nil
124
- # IRB.conf[:USE_COLORIZE] = true
125
- # IRB.conf[:USE_TRACER] = false
126
- # IRB.conf[:USE_AUTOCOMPLETE] = true
127
- # IRB.conf[:IGNORE_SIGINT] = true
128
- # IRB.conf[:IGNORE_EOF] = false
129
- # IRB.conf[:PROMPT_MODE] = :DEFAULT
130
- # IRB.conf[:PROMPT] = {...}
131
- #
132
- # === Auto indentation
133
- #
134
- # To disable auto-indent mode in irb, add the following to your +.irbrc+:
135
- #
136
- # IRB.conf[:AUTO_INDENT] = false
137
- #
138
- # === Autocompletion
139
- #
140
- # To disable autocompletion for irb, add the following to your +.irbrc+:
141
- #
142
- # IRB.conf[:USE_AUTOCOMPLETE] = false
143
- #
144
- # To enable enhanced completion using type information, add the following to your +.irbrc+:
145
- #
146
- # IRB.conf[:COMPLETOR] = :type
147
- #
148
- # === History
149
- #
150
- # By default, irb will store the last 1000 commands you used in
151
- # <code>IRB.conf[:HISTORY_FILE]</code> (<code>~/.irb_history</code> by default).
152
- #
153
- # If you want to disable history, add the following to your +.irbrc+:
154
- #
155
- # IRB.conf[:SAVE_HISTORY] = nil
156
- #
157
- # See IRB::Context#save_history= for more information.
158
- #
159
- # The history of _results_ of commands evaluated is not stored by default,
160
- # but can be turned on to be stored with this +.irbrc+ setting:
161
- #
162
- # IRB.conf[:EVAL_HISTORY] = <number>
163
- #
164
- # See IRB::Context#eval_history= and EvalHistory class. The history of command
165
- # results is not permanently saved in any file.
166
- #
167
- # == Customizing the IRB Prompt
168
- #
169
- # In order to customize the prompt, you can change the following Hash:
170
- #
171
- # IRB.conf[:PROMPT]
172
- #
173
- # This example can be used in your +.irbrc+
174
- #
175
- # IRB.conf[:PROMPT][:MY_PROMPT] = { # name of prompt mode
176
- # :AUTO_INDENT => false, # disables auto-indent mode
177
- # :PROMPT_I => ">> ", # simple prompt
178
- # :PROMPT_S => nil, # prompt for continuated strings
179
- # :PROMPT_C => nil, # prompt for continuated statement
180
- # :RETURN => " ==>%s\n" # format to return value
181
- # }
182
- #
183
- # IRB.conf[:PROMPT_MODE] = :MY_PROMPT
184
- #
185
- # Or, invoke irb with the above prompt mode by:
186
- #
187
- # irb --prompt my-prompt
188
- #
189
- # Constants +PROMPT_I+, +PROMPT_S+ and +PROMPT_C+ specify the format. In the
190
- # prompt specification, some special strings are available:
191
- #
192
- # %N # command name which is running
193
- # %m # to_s of main object (self)
194
- # %M # inspect of main object (self)
195
- # %l # type of string(", ', /, ]), `]' is inner %w[...]
196
- # %NNi # indent level. NN is digits and means as same as printf("%NNd").
197
- # # It can be omitted
198
- # %NNn # line number.
199
- # %% # %
200
- #
201
- # For instance, the default prompt mode is defined as follows:
202
- #
203
- # IRB.conf[:PROMPT_MODE][:DEFAULT] = {
204
- # :PROMPT_I => "%N(%m):%03n> ",
205
- # :PROMPT_S => "%N(%m):%03n%l ",
206
- # :PROMPT_C => "%N(%m):%03n* ",
207
- # :RETURN => "%s\n" # used to printf
208
- # }
209
- #
210
- # irb comes with a number of available modes:
211
- #
212
- # # :NULL:
213
- # # :PROMPT_I:
214
- # # :PROMPT_S:
215
- # # :PROMPT_C:
216
- # # :RETURN: |
217
- # # %s
218
- # # :DEFAULT:
219
- # # :PROMPT_I: ! '%N(%m):%03n> '
220
- # # :PROMPT_S: ! '%N(%m):%03n%l '
221
- # # :PROMPT_C: ! '%N(%m):%03n* '
222
- # # :RETURN: |
223
- # # => %s
224
- # # :CLASSIC:
225
- # # :PROMPT_I: ! '%N(%m):%03n:%i> '
226
- # # :PROMPT_S: ! '%N(%m):%03n:%i%l '
227
- # # :PROMPT_C: ! '%N(%m):%03n:%i* '
228
- # # :RETURN: |
229
- # # %s
230
- # # :SIMPLE:
231
- # # :PROMPT_I: ! '>> '
232
- # # :PROMPT_S:
233
- # # :PROMPT_C: ! '?> '
234
- # # :RETURN: |
235
- # # => %s
236
- # # :INF_RUBY:
237
- # # :PROMPT_I: ! '%N(%m):%03n> '
238
- # # :PROMPT_S:
239
- # # :PROMPT_C:
240
- # # :RETURN: |
241
- # # %s
242
- # # :AUTO_INDENT: true
243
- # # :XMP:
244
- # # :PROMPT_I:
245
- # # :PROMPT_S:
246
- # # :PROMPT_C:
247
- # # :RETURN: |2
248
- # # ==>%s
25
+ # == \IRB
249
26
  #
250
- # == Restrictions
27
+ # \Module \IRB ("Interactive Ruby") provides a shell-like interface
28
+ # that supports user interaction with the Ruby interpreter.
251
29
  #
252
- # Because irb evaluates input immediately after it is syntactically complete,
253
- # the results may be slightly different than directly using Ruby.
30
+ # It operates as a <i>read-eval-print loop</i>
31
+ # ({REPL}[https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop])
32
+ # that:
254
33
  #
255
- # == IRB Sessions
34
+ # - <b>_Reads_</b> each character as you type.
35
+ # You can modify the \IRB context to change the way input works.
36
+ # See {Input}[rdoc-ref:IRB@Input].
37
+ # - <b>_Evaluates_</b> the code each time it has read a syntactically complete passage.
38
+ # - <b>_Prints_</b> after evaluating.
39
+ # You can modify the \IRB context to change the way output works.
40
+ # See {Output}[rdoc-ref:IRB@Output].
256
41
  #
257
- # IRB has a special feature, that allows you to manage many sessions at once.
42
+ # Example:
258
43
  #
259
- # You can create new sessions with Irb.irb, and get a list of current sessions
260
- # with the +jobs+ command in the prompt.
44
+ # $ irb
45
+ # irb(main):001> File.basename(Dir.pwd)
46
+ # => "irb"
47
+ # irb(main):002> Dir.entries('.').size
48
+ # => 25
49
+ # irb(main):003* Dir.entries('.').select do |entry|
50
+ # irb(main):004* entry.start_with?('R')
51
+ # irb(main):005> end
52
+ # => ["README.md", "Rakefile"]
261
53
  #
262
- # === Commands
54
+ # The typed input may also include
55
+ # {\IRB-specific commands}[rdoc-ref:IRB@IRB-Specific+Commands].
56
+ #
57
+ # As seen above, you can start \IRB by using the shell command +irb+.
58
+ #
59
+ # You can stop an \IRB session by typing command +exit+:
60
+ #
61
+ # irb(main):006> exit
62
+ # $
63
+ #
64
+ # At that point, \IRB calls any hooks found in array <tt>IRB.conf[:AT_EXIT]</tt>,
65
+ # then exits.
66
+ #
67
+ # == Startup
68
+ #
69
+ # At startup, \IRB:
70
+ #
71
+ # 1. Interprets (as Ruby code) the content of the
72
+ # {configuration file}[rdoc-ref:IRB@Configuration+File] (if given).
73
+ # 1. Constructs the initial session context
74
+ # from {hash IRB.conf}[rdoc-ref:IRB@Hash+IRB.conf] and from default values;
75
+ # the hash content may have been affected
76
+ # by {command-line options}[rdoc-ref:IB@Command-Line+Options],
77
+ # and by direct assignments in the configuration file.
78
+ # 1. Assigns the context to variable +conf+.
79
+ # 1. Assigns command-line arguments to variable <tt>ARGV</tt>.
80
+ # 1. Prints the {prompt}[rdoc-ref:IRB@Prompt+and+Return+Formats].
81
+ # 1. Puts the content of the
82
+ # {initialization script}[rdoc-ref:IRB@Initialization+Script]
83
+ # onto the \IRB shell, just as if it were user-typed commands.
84
+ #
85
+ # === The Command Line
86
+ #
87
+ # On the command line, all options precede all arguments;
88
+ # the first item that is not recognized as an option is treated as an argument,
89
+ # as are all items that follow.
90
+ #
91
+ # ==== Command-Line Options
92
+ #
93
+ # Many command-line options affect entries in hash <tt>IRB.conf</tt>,
94
+ # which in turn affect the initial configuration of the \IRB session.
95
+ #
96
+ # Details of the options are described in the relevant subsections below.
97
+ #
98
+ # A cursory list of the \IRB command-line options
99
+ # may be seen in the {help message}[https://raw.githubusercontent.com/ruby/irb/master/lib/irb/lc/help-message],
100
+ # which is also displayed if you use command-line option <tt>--help</tt>.
101
+ #
102
+ # If you are interested in a specific option, consult the
103
+ # {index}[rdoc-ref:doc/irb/indexes.md@Index+of+Command-Line+Options].
104
+ #
105
+ # ==== Command-Line Arguments
106
+ #
107
+ # Command-line arguments are passed to \IRB in array +ARGV+:
108
+ #
109
+ # $ irb --noscript Foo Bar Baz
110
+ # irb(main):001> ARGV
111
+ # => ["Foo", "Bar", "Baz"]
112
+ # irb(main):002> exit
113
+ # $
114
+ #
115
+ # Command-line option <tt>--</tt> causes everything that follows
116
+ # to be treated as arguments, even those that look like options:
117
+ #
118
+ # $ irb --noscript -- --noscript -- Foo Bar Baz
119
+ # irb(main):001> ARGV
120
+ # => ["--noscript", "--", "Foo", "Bar", "Baz"]
121
+ # irb(main):002> exit
122
+ # $
123
+ #
124
+ # === Configuration File
125
+ #
126
+ # You can initialize \IRB via a <i>configuration file</i>.
127
+ #
128
+ # If command-line option <tt>-f</tt> is given,
129
+ # no configuration file is looked for.
130
+ #
131
+ # Otherwise, \IRB reads and interprets a configuration file
132
+ # if one is available.
133
+ #
134
+ # The configuration file can contain any Ruby code, and can usefully include
135
+ # user code that:
136
+ #
137
+ # - Can then be debugged in \IRB.
138
+ # - Configures \IRB itself.
139
+ # - Requires or loads files.
140
+ #
141
+ # The path to the configuration file is the first found among:
142
+ #
143
+ # - The value of variable <tt>$IRBRC</tt>, if defined.
144
+ # - The value of variable <tt>$XDG_CONFIG_HOME/irb/irbrc</tt>, if defined.
145
+ # - File <tt>$HOME/.irbrc</tt>, if it exists.
146
+ # - File <tt>$HOME/.config/irb/irbrc</tt>, if it exists.
147
+ # - File +.config/irb/irbrc+ in the current directory, if it exists.
148
+ # - File +.irbrc+ in the current directory, if it exists.
149
+ # - File +irb.rc+ in the current directory, if it exists.
150
+ # - File +_irbrc+ in the current directory, if it exists.
151
+ # - File <tt>$irbrc</tt> in the current directory, if it exists.
152
+ #
153
+ # If the search fails, there is no configuration file.
154
+ #
155
+ # If the search succeeds, the configuration file is read as Ruby code,
156
+ # and so can contain any Ruby programming you like.
157
+ #
158
+ # \Method <tt>conf.rc?</tt> returns +true+ if a configuration file was read,
159
+ # +false+ otherwise.
160
+ # \Hash entry <tt>IRB.conf[:RC]</tt> also contains that value.
161
+ #
162
+ # === \Hash <tt>IRB.conf</tt>
163
+ #
164
+ # The initial entries in hash <tt>IRB.conf</tt> are determined by:
165
+ #
166
+ # - Default values.
167
+ # - Command-line options, which may override defaults.
168
+ # - Direct assignments in the configuration file.
169
+ #
170
+ # You can see the hash by typing <tt>IRB.conf</tt>.
171
+ #
172
+ # Details of the entries' meanings are described in the relevant subsections below.
173
+ #
174
+ # If you are interested in a specific entry, consult the
175
+ # {index}[rdoc-ref:doc/irb/indexes.md@Index+of+IRB.conf+Entries].
176
+ #
177
+ # === Notes on Initialization Precedence
178
+ #
179
+ # - Any conflict between an entry in hash <tt>IRB.conf</tt> and a command-line option
180
+ # is resolved in favor of the hash entry.
181
+ # - \Hash <tt>IRB.conf</tt> affects the context only once,
182
+ # when the configuration file is interpreted;
183
+ # any subsequent changes to it do not affect the context
184
+ # and are therefore essentially meaningless.
185
+ #
186
+ # === Initialization Script
187
+ #
188
+ # By default, the first command-line argument (after any options)
189
+ # is the path to a Ruby initialization script.
190
+ #
191
+ # \IRB reads the initialization script and puts its content onto the \IRB shell,
192
+ # just as if it were user-typed commands.
193
+ #
194
+ # Command-line option <tt>--noscript</tt> causes the first command-line argument
195
+ # to be treated as an ordinary argument (instead of an initialization script);
196
+ # <tt>--script</tt> is the default.
197
+ #
198
+ # == Input
199
+ #
200
+ # This section describes the features that allow you to change
201
+ # the way \IRB input works;
202
+ # see also {Input and Output}[rdoc-ref:IRB@Input+and+Output].
203
+ #
204
+ # === Input Command History
205
+ #
206
+ # By default, \IRB stores a history of up to 1000 input commands
207
+ # in file <tt>~/.irb_history</tt>
208
+ # (or, if a {configuration file}[rdoc-ref:IRB@Configuration+File]
209
+ # is found, in file +.irb_history+
210
+ # inin the same directory as that file).
211
+ #
212
+ # A new \IRB session creates the history file if it does not exist,
213
+ # and appends to the file if it does exist.
214
+ #
215
+ # You can change the filepath by adding to your configuration file:
216
+ # <tt>IRB.conf[:HISTORY_FILE] = _filepath_</tt>,
217
+ # where _filepath_ is a string filepath.
218
+ #
219
+ # During the session, method <tt>conf.history_file</tt> returns the filepath,
220
+ # and method <tt>conf.history_file = <i>new_filepath</i></tt>
221
+ # copies the history to the file at <i>new_filepath</i>,
222
+ # which becomes the history file for the session.
223
+ #
224
+ # You can change the number of commands saved by adding to your configuration file:
225
+ # <tt>IRB.conf[:SAVE_HISTORY] = _n_</tt>,
226
+ # where _n_ is one of:
227
+ #
228
+ # - Positive integer: the number of commands to be saved,
229
+ # - Zero: all commands are to be saved.
230
+ # - +nil+: no commands are to be saved,.
231
+ #
232
+ # During the session, you can use
233
+ # methods <tt>conf.save_history</tt> or <tt>conf.save_history=</tt>
234
+ # to retrieve or change the count.
235
+ #
236
+ # === Command Aliases
237
+ #
238
+ # By default, \IRB defines several command aliases:
239
+ #
240
+ # irb(main):001> conf.command_aliases
241
+ # => {:"$"=>:show_source, :"@"=>:whereami}
242
+ #
243
+ # You can change the initial aliases in the configuration file with:
244
+ #
245
+ # IRB.conf[:COMMAND_ALIASES] = {foo: :show_source, bar: :whereami}
246
+ #
247
+ # You can replace the current aliases at any time
248
+ # with configuration method <tt>conf.command_aliases=</tt>;
249
+ # Because <tt>conf.command_aliases</tt> is a hash,
250
+ # you can modify it.
251
+ #
252
+ # === End-of-File
253
+ #
254
+ # By default, <tt>IRB.conf[:IGNORE_EOF]</tt> is +false+,
255
+ # which means that typing the end-of-file character <tt>Ctrl-D</tt>
256
+ # causes the session to exit.
257
+ #
258
+ # You can reverse that behavior by adding <tt>IRB.conf[:IGNORE_EOF] = true</tt>
259
+ # to the configuration file.
260
+ #
261
+ # During the session, method <tt>conf.ignore_eof?</tt> returns the setting,
262
+ # and method <tt>conf.ignore_eof = _boolean_</tt> sets it.
263
+ #
264
+ # === SIGINT
265
+ #
266
+ # By default, <tt>IRB.conf[:IGNORE_SIGINT]</tt> is +true+,
267
+ # which means that typing the interrupt character <tt>Ctrl-C</tt>
268
+ # causes the session to exit.
269
+ #
270
+ # You can reverse that behavior by adding <tt>IRB.conf[:IGNORE_SIGING] = false</tt>
271
+ # to the configuration file.
272
+ #
273
+ # During the session, method <tt>conf.ignore_siging?</tt> returns the setting,
274
+ # and method <tt>conf.ignore_sigint = _boolean_</tt> sets it.
275
+ #
276
+ # === Automatic Completion
277
+ #
278
+ # By default, \IRB enables
279
+ # {automatic completion}[https://en.wikipedia.org/wiki/Autocomplete#In_command-line_interpreters]:
280
+ #
281
+ # You can disable it by either of these:
282
+ #
283
+ # - Adding <tt>IRB.conf[:USE_AUTOCOMPLETE] = false</tt> to the configuration file.
284
+ # - Giving command-line option <tt>--noautocomplete</tt>
285
+ # (<tt>--autocomplete</tt> is the default).
286
+ #
287
+ # \Method <tt>conf.use_autocomplete?</tt> returns +true+
288
+ # if automatic completion is enabled, +false+ otherwise.
289
+ #
290
+ # The setting may not be changed during the session.
291
+ #
292
+ # === Automatic Indentation
293
+ #
294
+ # By default, \IRB automatically indents lines of code to show structure
295
+ # (e.g., it indent the contents of a block).
296
+ #
297
+ # The current setting is returned
298
+ # by the configuration method <tt>conf.auto_indent_mode</tt>.
299
+ #
300
+ # The default initial setting is +true+:
301
+ #
302
+ # irb(main):001> conf.auto_indent_mode
303
+ # => true
304
+ # irb(main):002* Dir.entries('.').select do |entry|
305
+ # irb(main):003* entry.start_with?('R')
306
+ # irb(main):004> end
307
+ # => ["README.md", "Rakefile"]
308
+ #
309
+ # You can change the initial setting in the
310
+ # configuration file with:
311
+ #
312
+ # IRB.conf[:AUTO_INDENT] = false
313
+ #
314
+ # Note that the _current_ setting <i>may not</i> be changed in the \IRB session.
315
+ #
316
+ # === Input \Method
317
+ #
318
+ # The \IRB input method determines how command input is to be read;
319
+ # by default, the input method for a session is IRB::RelineInputMethod.
320
+ #
321
+ # You can set the input method by:
322
+ #
323
+ # - Adding to the configuration file:
324
+ #
325
+ # - <tt>IRB.conf[:USE_SINGLELINE] = true</tt>
326
+ # or <tt>IRB.conf[:USE_MULTILINE]= false</tt>
327
+ # sets the input method to IRB::ReadlineInputMethod.
328
+ # - <tt>IRB.conf[:USE_SINGLELINE] = false</tt>
329
+ # or <tt>IRB.conf[:USE_MULTILINE] = true</tt>
330
+ # sets the input method to IRB::RelineInputMethod.
331
+ #
332
+ # - Giving command-line options:
333
+ #
334
+ # - <tt>--singleline</tt>
335
+ # or <tt>--nomultiline</tt>
336
+ # sets the input method to IRB::ReadlineInputMethod.
337
+ # - <tt>--nosingleline</tt>
338
+ # or <tt>--multiline/tt>
339
+ # sets the input method to IRB::RelineInputMethod.
340
+ #
341
+ # \Method <tt>conf.use_multiline?</tt>
342
+ # and its synonym <tt>conf.use_reline</tt> return:
343
+ #
344
+ # - +true+ if option <tt>--multiline</tt> was given.
345
+ # - +false+ if option <tt>--nomultiline</tt> was given.
346
+ # - +nil+ if neither was given.
347
+ #
348
+ # \Method <tt>conf.use_singleline?</tt>
349
+ # and its synonym <tt>conf.use_readline</tt> return:
350
+ #
351
+ # - +true+ if option <tt>--singleline</tt> was given.
352
+ # - +false+ if option <tt>--nosingleline</tt> was given.
353
+ # - +nil+ if neither was given.
354
+ #
355
+ # == Output
356
+ #
357
+ # This section describes the features that allow you to change
358
+ # the way \IRB output works;
359
+ # see also {Input and Output}[rdoc-ref:IRB@Input+and+Output].
360
+ #
361
+ # === Return-Value Printing (Echoing)
362
+ #
363
+ # By default, \IRB prints (echoes) the values returned by all input commands.
364
+ #
365
+ # You can change the initial behavior and suppress all echoing by:
366
+ #
367
+ # - Adding to the configuration file: <tt>IRB.conf[:ECHO] = false</tt>.
368
+ # (The default value for this entry is +niL+, which means the same as +true+.)
369
+ # - Giving command-line option <tt>--noecho</tt>.
370
+ # (The default is <tt>--echo</tt>.)
371
+ #
372
+ # During the session, you can change the current setting
373
+ # with configuration method <tt>conf.echo=</tt> (set to +true+ or +false+).
374
+ #
375
+ # As stated above, by default \IRB prints the values returned by all input commands;
376
+ # but \IRB offers special treatment for values returned by assignment statements,
377
+ # which may be:
378
+ #
379
+ # - Printed with truncation (to fit on a single line of output),
380
+ # which is the default;
381
+ # an ellipsis (<tt>...</tt> is suffixed, to indicate the truncation):
382
+ #
383
+ # irb(main):001> x = 'abc' * 100
384
+ # => "abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc...
385
+ #
386
+ # - Printed in full (regardless of the length).
387
+ # - Suppressed (not printed at all)
388
+ #
389
+ # You can change the initial behavior by:
390
+ #
391
+ # - Adding to the configuration file: <tt>IRB.conf[:ECHO_ON_ASSIGNMENT] = false</tt>.
392
+ # (The default value for this entry is +niL+, which means the same as +:truncate+.)
393
+ # - Giving command-line option <tt>--noecho-on-assignment</tt>
394
+ # or <tt>--echo-on-assignment</tt>.
395
+ # (The default is <tt>--truncate-echo-on-assigment</tt>.)
396
+ #
397
+ # During the session, you can change the current setting
398
+ # with configuration method <tt>conf.echo_on_assignment=</tt>
399
+ # (set to +true+, +false+, or +:truncate+).
400
+ #
401
+ # By default, \IRB formats returned values by calling method +inspect+.
402
+ #
403
+ # You can change the initial behavior by:
404
+ #
405
+ # - Adding to the configuration file: <tt>IRB.conf[:INSPECT_MODE] = false</tt>.
406
+ # (The default value for this entry is +true+.)
407
+ # - Giving command-line option <tt>--noinspect</tt>.
408
+ # (The default is <tt>--inspect</tt>.)
409
+ #
410
+ # During the session, you can change the setting using method <tt>conf.inspect_mode=</tt>.
411
+ #
412
+ # === Multiline Output
413
+ #
414
+ # By default, \IRB prefixes a newline to a multiline response.
415
+ #
416
+ # You can change the initial default value by adding to the configuation file:
417
+ #
418
+ # IRB.conf[:NEWLINE_BEFORE_MULTILINE_OUTPUT] = false
419
+ #
420
+ # During a session, you can retrieve or set the value using
421
+ # methods <tt>conf.newline_before_multiline_output?</tt>
422
+ # and <tt>conf.newline_before_multiline_output=</tt>.
423
+ #
424
+ # Examples:
425
+ #
426
+ # irb(main):001> conf.inspect_mode = false
427
+ # => false
428
+ # irb(main):002> "foo\nbar"
429
+ # =>
430
+ # foo
431
+ # bar
432
+ # irb(main):003> conf.newline_before_multiline_output = false
433
+ # => false
434
+ # irb(main):004> "foo\nbar"
435
+ # => foo
436
+ # bar
437
+ #
438
+ # === Evaluation History
439
+ #
440
+ # By default, \IRB saves no history of evaluations (returned values),
441
+ # and the related methods <tt>conf.eval_history</tt>, <tt>_</tt>,
442
+ # and <tt>__</tt> are undefined.
443
+ #
444
+ # You can turn on that history, and set the maximum number of evaluations to be stored:
445
+ #
446
+ # - In the configuration file: add <tt>IRB.conf[:EVAL_HISTORY] = _n_</tt>.
447
+ # (Examples below assume that we've added <tt>IRB.conf[:EVAL_HISTORY] = 5</tt>.)
448
+ # - In the session (at any time): <tt>conf.eval_history = _n_</tt>.
449
+ #
450
+ # If +n+ is zero, all evaluation history is stored.
451
+ #
452
+ # Doing either of the above:
453
+ #
454
+ # - Sets the maximum size of the evaluation history;
455
+ # defines method <tt>conf.eval_history</tt>,
456
+ # which returns the maximum size +n+ of the evaluation history:
457
+ #
458
+ # irb(main):001> conf.eval_history = 5
459
+ # => 5
460
+ # irb(main):002> conf.eval_history
461
+ # => 5
462
+ #
463
+ # - Defines variable <tt>_</tt>, which contains the most recent evaluation,
464
+ # or +nil+ if none; same as method <tt>conf.last_value</tt>:
263
465
  #
264
- # JobManager provides commands to handle the current sessions:
466
+ # irb(main):003> _
467
+ # => 5
468
+ # irb(main):004> :foo
469
+ # => :foo
470
+ # irb(main):005> :bar
471
+ # => :bar
472
+ # irb(main):006> _
473
+ # => :bar
474
+ # irb(main):007> _
475
+ # => :bar
265
476
  #
266
- # jobs # List of current sessions
267
- # fg # Switches to the session of the given number
268
- # kill # Kills the session with the given number
477
+ # - Defines variable <tt>__</tt>:
269
478
  #
270
- # The +exit+ command, or ::irb_exit, will quit the current session and call any
271
- # exit hooks with IRB.irb_at_exit.
479
+ # - <tt>__</tt> unadorned: contains all evaluation history:
272
480
  #
273
- # A few commands for loading files within the session are also available:
481
+ # irb(main):008> :foo
482
+ # => :foo
483
+ # irb(main):009> :bar
484
+ # => :bar
485
+ # irb(main):010> :baz
486
+ # => :baz
487
+ # irb(main):011> :bat
488
+ # => :bat
489
+ # irb(main):012> :bam
490
+ # => :bam
491
+ # irb(main):013> __
492
+ # =>
493
+ # 9 :bar
494
+ # 10 :baz
495
+ # 11 :bat
496
+ # 12 :bam
497
+ # irb(main):014> __
498
+ # =>
499
+ # 10 :baz
500
+ # 11 :bat
501
+ # 12 :bam
502
+ # 13 ...self-history...
274
503
  #
275
- # +source+::
276
- # Loads a given file in the current session and displays the source lines,
277
- # see IrbLoader#source_file
278
- # +irb_load+::
279
- # Loads the given file similarly to Kernel#load, see IrbLoader#irb_load
280
- # +irb_require+::
281
- # Loads the given file similarly to Kernel#require
504
+ # Note that when the evaluation is multiline, it is displayed differently.
282
505
  #
283
- # === Configuration
506
+ # - <tt>__[</tt>_m_<tt>]</tt>:
507
+ #
508
+ # - Positive _m_: contains the evaluation for the given line number,
509
+ # or +nil+ if that line number is not in the evaluation history:
510
+ #
511
+ # irb(main):015> __[12]
512
+ # => :bam
513
+ # irb(main):016> __[1]
514
+ # => nil
515
+ #
516
+ # - Negative _m_: contains the +mth+-from-end evaluation,
517
+ # or +nil+ if that evaluation is not in the evaluation history:
518
+ #
519
+ # irb(main):017> __[-3]
520
+ # => :bam
521
+ # irb(main):018> __[-13]
522
+ # => nil
523
+ #
524
+ # - Zero _m_: contains +nil+:
525
+ #
526
+ # irb(main):019> __[0]
527
+ # => nil
528
+ #
529
+ # === Prompt and Return Formats
530
+ #
531
+ # By default, \IRB uses the prompt and return value formats
532
+ # defined in its +:DEFAULT+ prompt mode.
533
+ #
534
+ # ==== The Default Prompt and Return Format
535
+ #
536
+ # The default prompt and return values look like this:
537
+ #
538
+ # irb(main):001> 1 + 1
539
+ # => 2
540
+ # irb(main):002> 2 + 2
541
+ # => 4
542
+ #
543
+ # The prompt includes:
544
+ #
545
+ # - The name of the running program (<tt>irb</tt>);
546
+ # see {IRB Name}[rdoc-ref:IRB@IRB+Name].
547
+ # - The name of the current session (<tt>main</tt>);
548
+ # See {IRB Sessions}[rdoc-ref:IRB@IRB+Sessions].
549
+ # - A 3-digit line number (1-based).
550
+ #
551
+ # The default prompt actually defines three formats:
552
+ #
553
+ # - One for most situations (as above):
554
+ #
555
+ # irb(main):003> Dir
556
+ # => Dir
557
+ #
558
+ # - One for when the typed command is a statement continuation (adds trailing asterisk):
559
+ #
560
+ # irb(main):004* Dir.
561
+ #
562
+ # - One for when the typed command is a string continuation (adds trailing single-quote):
563
+ #
564
+ # irb(main):005' Dir.entries('.
565
+ #
566
+ # You can see the prompt change as you type the characters in the following:
567
+ #
568
+ # irb(main):001* Dir.entries('.').select do |entry|
569
+ # irb(main):002* entry.start_with?('R')
570
+ # irb(main):003> end
571
+ # => ["README.md", "Rakefile"]
572
+ #
573
+ # ==== Pre-Defined Prompts
574
+ #
575
+ # \IRB has several pre-defined prompts, stored in hash <tt>IRB.conf[:PROMPT]</tt>:
576
+ #
577
+ # irb(main):001> IRB.conf[:PROMPT].keys
578
+ # => [:NULL, :DEFAULT, :CLASSIC, :SIMPLE, :INF_RUBY, :XMP]
579
+ #
580
+ # To see the full data for these, type <tt>IRB.conf[:PROMPT]</tt>.
581
+ #
582
+ # Most of these prompt definitions include specifiers that represent
583
+ # values like the \IRB name, session name, and line number;
584
+ # see {Prompt Specifiers}[rdoc-ref:IRB@Prompt+Specifiers].
585
+ #
586
+ # You can change the initial prompt and return format by:
587
+ #
588
+ # - Adding to the configuration file: <tt>IRB.conf[:PROMPT] = _mode_</tt>
589
+ # where _mode_ is the symbol name of a prompt mode.
590
+ # - Giving a command-line option:
591
+ #
592
+ # - <tt>--prompt _mode_</tt>: sets the prompt mode to _mode_.
593
+ # where _mode_ is the symbol name of a prompt mode.
594
+ # - <tt>--simple-prompt</tt> or <tt>--sample-book-mode</tt>:
595
+ # sets the prompt mode to +:SIMPLE+.
596
+ # - <tt>--inf-ruby-mode</tt>: sets the prompt mode to +:INF_RUBY+
597
+ # and suppresses both <tt>--multiline</tt> and <tt>--singleline</tt>.
598
+ # - <tt>--noprompt</tt>: suppresses prompting; does not affect echoing.
599
+ #
600
+ # You can retrieve or set the current prompt mode with methods
601
+ #
602
+ # <tt>conf.prompt_mode</tt> and <tt>conf.prompt_mode=</tt>.
603
+ #
604
+ # If you're interested in prompts and return formats other than the defaults,
605
+ # you might experiment by trying some of the others.
606
+ #
607
+ # ==== Custom Prompts
608
+ #
609
+ # You can also define custom prompts and return formats,
610
+ # which may be done either in an \IRB session or in the configuration file.
611
+ #
612
+ # A prompt in \IRB actually defines three prompts, as seen above.
613
+ # For simple custom data, we'll make all three the same:
614
+ #
615
+ # irb(main):001* IRB.conf[:PROMPT][:MY_PROMPT] = {
616
+ # irb(main):002* PROMPT_I: ': ',
617
+ # irb(main):003* PROMPT_C: ': ',
618
+ # irb(main):004* PROMPT_S: ': ',
619
+ # irb(main):005* RETURN: '=> '
620
+ # irb(main):006> }
621
+ # => {:PROMPT_I=>": ", :PROMPT_C=>": ", :PROMPT_S=>": ", :RETURN=>"=> "}
622
+ #
623
+ # If you define the custom prompt in the configuration file,
624
+ # you can also make it the current prompt by adding:
625
+ #
626
+ # IRB.conf[:PROMPT_MODE] = :MY_PROMPT
627
+ #
628
+ # Regardless of where it's defined, you can make it the current prompt in a session:
629
+ #
630
+ # conf.prompt_mode = :MY_PROMPT
631
+ #
632
+ # You can view or modify the current prompt data with various configuration methods:
633
+ #
634
+ # - <tt>conf.prompt_mode</tt>, <tt>conf.prompt_mode=</tt>.
635
+ # - <tt>conf.prompt_c</tt>, <tt>conf.c=</tt>.
636
+ # - <tt>conf.prompt_i</tt>, <tt>conf.i=</tt>.
637
+ # - <tt>conf.prompt_s</tt>, <tt>conf.s=</tt>.
638
+ # - <tt>conf.return_format</tt>, <tt>return_format=</tt>.
639
+ #
640
+ # ==== Prompt Specifiers
641
+ #
642
+ # A prompt's definition can include specifiers for which certain values are substituted:
643
+ #
644
+ # - <tt>%N</tt>: the name of the running program.
645
+ # - <tt>%m</tt>: the value of <tt>self.to_s</tt>.
646
+ # - <tt>%M</tt>: the value of <tt>self.inspect</tt>.
647
+ # - <tt>%l</tt>: an indication of the type of string;
648
+ # one of <tt>"</tt>, <tt>'</tt>, <tt>/</tt>, <tt>]</tt>.
649
+ # - <tt><i>NN</i>i</tt>: Indentation level.
650
+ # - <tt><i>NN</i>n</tt>: Line number.
651
+ # - <tt>%%</tt>: Literal <tt>%</tt>.
652
+ #
653
+ # === Verbosity
654
+ #
655
+ # By default, \IRB verbosity is disabled, which means that output is smaller
656
+ # rather than larger.
657
+ #
658
+ # You can enable verbosity by:
659
+ #
660
+ # - Adding to the configuration file: <tt>IRB.conf[:VERBOSE] = true</tt>
661
+ # (the default is +nil+).
662
+ # - Giving command-line options <tt>--verbose</tt>
663
+ # (the default is <tt>--noverbose</tt>).
664
+ #
665
+ # During a session, you can retrieve or set verbosity with methods
666
+ # <tt>conf.verbose</tt> and <tt>conf.verbose=</tt>.
667
+ #
668
+ # === Help
669
+ #
670
+ # Command-line option <tt>--version</tt> causes \IRB to print its help text
671
+ # and exit.
672
+ #
673
+ # === Version
674
+ #
675
+ # Command-line option <tt>--version</tt> causes \IRB to print its version text
676
+ # and exit.
677
+ #
678
+ # == Input and Output
679
+ #
680
+ # === \Color Highlighting
681
+ #
682
+ # By default, \IRB color highlighting is enabled, and is used for both:
683
+ #
684
+ # - Input: As you type, \IRB reads the typed characters and highlights
685
+ # elements that it recognizes;
686
+ # it also highlights errors such as mismatched parentheses.
687
+ # - Output: \IRB highlights syntactical elements.
688
+ #
689
+ # You can disable color highlighting by:
690
+ #
691
+ # - Adding to the configuration file: <tt>IRB.conf[:USE_COLORIZE] = false</tt>
692
+ # (the default value is +true+).
693
+ # - Giving command-line option <tt>--nocolorize</tt>
694
+ #
695
+ # == Debugging
696
+ #
697
+ # Command-line option <tt>-d</tt> sets variables <tt>$VERBOSE</tt>
698
+ # and <tt>$DEBUG</tt> to +true+;
699
+ # these have no effect on \IRB output.
700
+ #
701
+ # === Warnings
702
+ #
703
+ # Command-line option <tt>-w</tt> suppresses warnings.
704
+ #
705
+ # Command-line option <tt>-W[_level_]<tt>
706
+ # sets warning level; 0=silence, 1=medium, 2=verbose.
707
+ #
708
+ # :stopdoc:
709
+ # === Performance Measurement
710
+ #
711
+ # IRB.conf[:MEASURE] IRB.conf[:MEASURE_CALLBACKS] IRB.conf[:MEASURE_PROC]
712
+ # :startdoc:
713
+ #
714
+ # == Other Features
715
+ #
716
+ # === Load Modules
717
+ #
718
+ # You can specify the names of modules that are to be required at startup.
719
+ #
720
+ # \Array <tt>conf.load_modules</tt> determines the modules (if any)
721
+ # that are to be required during session startup.
722
+ # The array is used only during session startup,
723
+ # so the initial value is the only one that counts.
724
+ #
725
+ # The default initial value is <tt>[]</tt> (load no modules):
726
+ #
727
+ # irb(main):001> conf.load_modules
728
+ # => []
729
+ #
730
+ # You can set the default initial value via:
731
+ #
732
+ # - Command-line option <tt>-r</tt>
733
+ #
734
+ # $ irb -r csv -r json
735
+ # irb(main):001> conf.load_modules
736
+ # => ["csv", "json"]
737
+ #
738
+ # - \Hash entry <tt>IRB.conf[:LOAD_MODULES] = _array_</tt>:
739
+ #
740
+ # IRB.conf[:LOAD_MODULES] = %w[csv, json]
741
+ #
742
+ # Note that the configuration file entry overrides the command-line options.
743
+ #
744
+ # === RI Documentation Directories
745
+ #
746
+ # You can specify the paths to RI documentation directories
747
+ # that are to be loaded (in addition to the default directories) at startup;
748
+ # see details about RI by typing <tt>ri --help</tt>.
749
+ #
750
+ # \Array <tt>conf.extra_doc_dirs</tt> determines the directories (if any)
751
+ # that are to be loaded during session startup.
752
+ # The array is used only during session startup,
753
+ # so the initial value is the only one that counts.
754
+ #
755
+ # The default initial value is <tt>[]</tt> (load no extra documentation):
756
+ #
757
+ # irb(main):001> conf.extra_doc_dirs
758
+ # => []
759
+ #
760
+ # You can set the default initial value via:
761
+ #
762
+ # - Command-line option <tt>--extra_doc_dir</tt>
763
+ #
764
+ # $ irb --extra-doc-dir your_doc_dir --extra-doc-dir my_doc_dir
765
+ # irb(main):001> conf.extra_doc_dirs
766
+ # => ["your_doc_dir", "my_doc_dir"]
767
+ #
768
+ # - \Hash entry <tt>IRB.conf[:EXTRA_DOC_DIRS] = _array_</tt>:
769
+ #
770
+ # IRB.conf[:EXTRA_DOC_DIRS] = %w[your_doc_dir my_doc_dir]
771
+ #
772
+ # Note that the configuration file entry overrides the command-line options.
773
+ #
774
+ # :stopdoc:
775
+ # === \Context Mode
776
+ #
777
+ # IRB.conf[:CONTEXT_MODE]
778
+ # :startdoc:
779
+ #
780
+ # === \IRB Name
781
+ #
782
+ # You can specify a name for \IRB.
783
+ #
784
+ # The default initial value is <tt>'irb'</tt>:
785
+ #
786
+ # irb(main):001> conf.irb_name
787
+ # => "irb"
788
+ #
789
+ # You can set the default initial value
790
+ # via hash entry <tt>IRB.conf[:IRB_NAME] = _string_</tt>:
791
+ #
792
+ # IRB.conf[:IRB_NAME] = 'foo'
793
+ #
794
+ # === Application Name
795
+ #
796
+ # You can specify an application name for the \IRB session.
797
+ #
798
+ # The default initial value is <tt>'irb'</tt>:
799
+ #
800
+ # irb(main):001> conf.ap_name
801
+ # => "irb"
802
+ #
803
+ # You can set the default initial value
804
+ # via hash entry <tt>IRB.conf[:AP_NAME] = _string_</tt>:
805
+ #
806
+ # IRB.conf[:AP_NAME] = 'my_ap_name'
807
+ #
808
+ # === Configuration Monitor
809
+ #
810
+ # You can monitor changes to the configuration by assigning a proc
811
+ # to <tt>IRB.conf[:IRB_RC]</tt> in the configuration file:
812
+ #
813
+ # IRB.conf[:IRB_RC] = proc {|conf| puts conf.class }
814
+ #
815
+ # Each time the configuration is changed,
816
+ # that proc is called with argument +conf+:
817
+ #
818
+ # :stopdoc:
819
+ # === \Locale
820
+ #
821
+ # IRB.conf[:LC_MESSAGES]
822
+ # :startdoc:
823
+ #
824
+ # === Encodings
825
+ #
826
+ # Command-line option <tt>-E _ex_[:_in_]</tt>
827
+ # sets initial external (ex) and internal (in) encodings.
828
+ #
829
+ # Command-line option <tt>-U</tt> sets both to UTF-8.
830
+ #
831
+ # === Commands
832
+ #
833
+ # Please use the `show_cmds` command to see the list of available commands.
834
+ #
835
+ # === IRB Sessions
836
+ #
837
+ # IRB has a special feature, that allows you to manage many sessions at once.
838
+ #
839
+ # You can create new sessions with Irb.irb, and get a list of current sessions
840
+ # with the +jobs+ command in the prompt.
841
+ #
842
+ # ==== Configuration
284
843
  #
285
844
  # The command line options, or IRB.conf, specify the default behavior of
286
845
  # Irb.irb.
287
846
  #
288
- # On the other hand, each conf in IRB@Command+line+options is used to
847
+ # On the other hand, each conf in IRB@Command-Line+Options is used to
289
848
  # individually configure IRB.irb.
290
849
  #
291
850
  # If a proc is set for <code>IRB.conf[:IRB_RC]</code>, its will be invoked after execution
292
851
  # of that proc with the context of the current session as its argument. Each
293
852
  # session can be configured using this mechanism.
294
853
  #
295
- # === Session variables
854
+ # ==== Session variables
296
855
  #
297
856
  # There are a few variables in every Irb session that can come in handy:
298
857
  #
@@ -307,66 +866,14 @@ require_relative "irb/pager"
307
866
  # If +line_no+ is a negative, the return value +line_no+ many lines before
308
867
  # the most recent return value.
309
868
  #
310
- # === Example using IRB Sessions
311
- #
312
- # # invoke a new session
313
- # irb(main):001:0> irb
314
- # # list open sessions
315
- # irb.1(main):001:0> jobs
316
- # #0->irb on main (#<Thread:0x400fb7e4> : stop)
317
- # #1->irb#1 on main (#<Thread:0x40125d64> : running)
318
- #
319
- # # change the active session
320
- # irb.1(main):002:0> fg 0
321
- # # define class Foo in top-level session
322
- # irb(main):002:0> class Foo;end
323
- # # invoke a new session with the context of Foo
324
- # irb(main):003:0> irb Foo
325
- # # define Foo#foo
326
- # irb.2(Foo):001:0> def foo
327
- # irb.2(Foo):002:1> print 1
328
- # irb.2(Foo):003:1> end
329
- #
330
- # # change the active session
331
- # irb.2(Foo):004:0> fg 0
332
- # # list open sessions
333
- # irb(main):004:0> jobs
334
- # #0->irb on main (#<Thread:0x400fb7e4> : running)
335
- # #1->irb#1 on main (#<Thread:0x40125d64> : stop)
336
- # #2->irb#2 on Foo (#<Thread:0x4011d54c> : stop)
337
- # # check if Foo#foo is available
338
- # irb(main):005:0> Foo.instance_methods #=> [:foo, ...]
339
- #
340
- # # change the active session
341
- # irb(main):006:0> fg 2
342
- # # define Foo#bar in the context of Foo
343
- # irb.2(Foo):005:0> def bar
344
- # irb.2(Foo):006:1> print "bar"
345
- # irb.2(Foo):007:1> end
346
- # irb.2(Foo):010:0> Foo.instance_methods #=> [:bar, :foo, ...]
347
- #
348
- # # change the active session
349
- # irb.2(Foo):011:0> fg 0
350
- # irb(main):007:0> f = Foo.new #=> #<Foo:0x4010af3c>
351
- # # invoke a new session with the context of f (instance of Foo)
352
- # irb(main):008:0> irb f
353
- # # list open sessions
354
- # irb.3(<Foo:0x4010af3c>):001:0> jobs
355
- # #0->irb on main (#<Thread:0x400fb7e4> : stop)
356
- # #1->irb#1 on main (#<Thread:0x40125d64> : stop)
357
- # #2->irb#2 on Foo (#<Thread:0x4011d54c> : stop)
358
- # #3->irb#3 on #<Foo:0x4010af3c> (#<Thread:0x4010a1e0> : running)
359
- # # evaluate f.foo
360
- # irb.3(<Foo:0x4010af3c>):002:0> foo #=> 1 => nil
361
- # # evaluate f.bar
362
- # irb.3(<Foo:0x4010af3c>):003:0> bar #=> bar => nil
363
- # # kill jobs 1, 2, and 3
364
- # irb.3(<Foo:0x4010af3c>):004:0> kill 1, 2, 3
365
- # # list open sessions, should only include main session
366
- # irb(main):009:0> jobs
367
- # #0->irb on main (#<Thread:0x400fb7e4> : running)
368
- # # quit irb
369
- # irb(main):010:0> exit
869
+ # == Restrictions
870
+ #
871
+ # Ruby code typed into \IRB behaves the same as Ruby code in a file, except that:
872
+ #
873
+ # - Because \IRB evaluates input immediately after it is syntactically complete,
874
+ # some results may be slightly different.
875
+ # - Forking may not be well behaved.
876
+ #
370
877
  module IRB
371
878
 
372
879
  # An exception raised by IRB.irb_abort
@@ -1023,8 +1530,7 @@ class Binding
1023
1530
  # irb(#<Potato:0x00007feea1916670>):005:0> exit
1024
1531
  # Cooked potato: true
1025
1532
  #
1026
- #
1027
- # See IRB@Usage for more information.
1533
+ # See IRB for more information.
1028
1534
  def irb(show_code: true)
1029
1535
  # Setup IRB with the current file's path and no command line arguments
1030
1536
  IRB.setup(source_location[0], argv: [])