Application 2024-10-20

Code Reading of irb

Explore the inner workings of Ruby's interactive shell (irb) and understand its startup process, history loading, and command execution.

Read in: ja
Code Reading of irb

Overview

Reading the code of irb.

Preparation

  1. Clone the irb source code
  1. Modify the entry point Since the original state runs the irb located in the Ruby installation directory, we will run the local irb instead.
#!/usr/bin/env ruby
#
#   irb.rb - interactive ruby
#    by Keiju ISHITSUKA(keiju@ruby-lang.org)
#

$LOAD_PATH.unshift(File.expand_path("../lib", __dir__)) # Add this line
require "irb"

IRB.start(__FILE__)
  1. Debug at any point

Code Reading

  1. Executing the irb command
  1. Setup process at startup
  1. Starting irb
  1. Executing input values
Tags: irb Ruby
Share: 𝕏 Post Facebook Hatena
✏️ View source / Discuss on GitHub
☕ Support

If you enjoy this blog, consider supporting it. Every bit helps keep it running!


Related Articles