Bug report: $irbrc does not affect IRB

In both the IRB from Ruby 1.6.4 and irb-0.9-02.07.03.tgz from RAA,
there appears to be a bug in the handling of $irbrc: it’s ignored.

I think the problem is in init.rb, here:

def IRB.run_config
if @CONF[:RC]
rcs = []
rcs.push File.expand_path("~/.irbrc") if ENV.key?(“HOME”)
rcs.push ".irbrc"
rcs.push "irb.rc"
rcs.push "_irbrc"
rcs.push “$irbrc” ### Here
# now try each file.

Note the quotes around “$irbrc”. I suggest the last line read like this:

   rcs.push $irbrc if $irbrc

That works when I try it.

···

I’m tempted to suggest that $irbrc come first in the list of init
files to try, rather than last. I’m tweaking IRB to be a command-line
interface to an application. I have to delete HOME from ENV to avoid
having ~/.irbrc loaded instead of the application-specific init file
$irbrc names.

Since I may be the first person ever to use $irbrc, it seems unlikely
the change would break someone else’s code. However, it would make a
lie of the sentence in Programming Ruby that describes the load
order.

If I told you this mail message would have an attachment, it doesn’t
seem to, and you use Outlook to read mail: you’ve probably been
bitten by an Outlook bug. The attachment is really there, Outlook
just isn’t showing it to you. You can still save it with File | Save
Attachments. (If that doesn’t work, I must have forgotten to attach
the file.) I’m sad when my choice of a Macintosh and the Eudora
mailer is an inconvenience to others.

“Act always so as to increase the number of choices.” – Heinz von Foerster


Brian Marick, marick@testing.com
www.testing.com - Software testing services and resources
www.testingcraft.com - Where software testers exchange techniques
www.visibleworkings.com - Adequate understanding of system internals

Brian Marick marick@testing.com writes:

Since I may be the first person ever to use $irbrc, it seems unlikely
the change would break someone else’s code. However, it would make a
lie of the sentence in Programming Ruby that describes the load
order.

We could give you a big bottle of white-out and a pen,and send you off
to correct them all…

Hi,

Brian Marick marick@testing.com writes:

In both the IRB from Ruby 1.6.4 and irb-0.9-02.07.03.tgz from RAA,
there appears to be a bug in the handling of $irbrc: it’s ignored.

I think the problem is in init.rb, here:

def IRB.run_config
if @CONF[:RC]
rcs =
rcs.push File.expand_path(“~/.irbrc”) if ENV.key?(“HOME”)
rcs.push “.irbrc”
rcs.push “irb.rc”
rcs.push “_irbrc”
rcs.push “$irbrc” ### Here
# now try each file.

Note the quotes around “$irbrc”. I suggest the last line read like this:

   rcs.push $irbrc if $irbrc

That works when I try it.

A file name called $irbrc exists for BOW.
BOW stands for “BSD on Windows”.

http://www.ascii.co.jp/books/detail/4-7561/4-7561-0305-7.html
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-dev/2405
Both are written in Japanese.

However, BOW is hardly used any longer and don’t refer to
this file name for it.

···


eban

Interesting! Should I make an RCR that IRB obey a global variable $irbrc rather than (in addition to?) the file named by the string "$irbrc"?

···

At 12:15 PM +0900 8/27/02, WATANABE Hirofumi wrote:

Hi,

Brian Marick <marick@testing.com> writes:

In both the IRB from Ruby 1.6.4 and irb-0.9-02.07.03.tgz from RAA,
there appears to be a bug in the handling of $irbrc: it's ignored.

I think the problem is in init.rb, here:

def IRB.run_config
      if @CONF[:RC]
        rcs =
        rcs.push File.expand_path("~/.irbrc") if ENV.key?("HOME")
        rcs.push ".irbrc"
        rcs.push "irb.rc"
        rcs.push "_irbrc"
        rcs.push "$irbrc" ### Here
        # now try each file.

Note the quotes around "$irbrc". I suggest the last line read like this:

        rcs.push $irbrc if $irbrc

That works when I try it.

A file name called $irbrc exists for BOW.
BOW stands for "BSD on Windows".

--
--
If I told you this mail message would have an attachment, it doesn't seem to, and you use Outlook to read mail: you've probably been bitten by an Outlook bug. The attachment is really there, Outlook just isn't showing it to you. You can still save it with File | Save Attachments. (If that doesn't work, I must have forgotten to attach the file.) I'm sad when my choice of a Macintosh and the Eudora mailer is an inconvenience to others.

"Act always so as to increase the number of choices." -- Heinz von Foerster

--
Brian Marick, marick@testing.com
www.testing.com - Software testing services and resources
www.testingcraft.com - Where software testers exchange techniques
www.visibleworkings.com - Adequate understanding of system internals

I would be happy to correct every copy brought to the Ruby Conference.

···

At 6:15 AM +0900 8/27/02, Dave Thomas wrote:

Brian Marick <marick@testing.com> writes:

Since I may be the first person ever to use $irbrc, it seems unlikely
the change would break someone else's code. However, it would make a
lie of the sentence in _Programming Ruby_ that describes the load
order.

We could give you a big bottle of white-out and a pen,and send you off
to correct them all...

--
--
If I told you this mail message would have an attachment, it doesn't seem to, and you use Outlook to read mail: you've probably been bitten by an Outlook bug. The attachment is really there, Outlook just isn't showing it to you. You can still save it with File | Save Attachments. (If that doesn't work, I must have forgotten to attach the file.) I'm sad when my choice of a Macintosh and the Eudora mailer is an inconvenience to others.

"Act always so as to increase the number of choices." -- Heinz von Foerster

--
Brian Marick, marick@testing.com
www.testing.com - Software testing services and resources
www.testingcraft.com - Where software testers exchange techniques
www.visibleworkings.com - Adequate understanding of system internals

Hi,

···

In message “Re: Bug report: $irbrc does not affect IRB” on 02/08/29, Brian Marick marick@visibleworkings.com writes:

A file name called $irbrc exists for BOW.
BOW stands for “BSD on Windows”.

Interesting! Should I make an RCR that IRB obey a global variable
$irbrc rather than (in addition to?) the file named by the string
“$irbrc”?

Then who should set up the value of $irbrc?

						matz.

Hi,

In [ruby-talk:48526] the message: “Bug report: $irbrc does not affect
IRB”, on Aug/29 13:34(JST) Yukihiro Matsumoto writes:

Interesting! Should I make an RCR that IRB obey a global variable
$irbrc rather than (in addition to?) the file named by the string
“$irbrc”?

Then who should set up the value of $irbrc?

Maybe, for embedding irb to another application. I don’t think
positively support for embedding irb at the moment.

You can redefine Irb.run_config in your application.

def IRB.run_config
if @CONF[:RC]
rcs =
rcs.push File.expand_path(“~/.an_app_rc”) if ENV.key?(“HOME”)
:

or you can write .irbrc next:

if $0 == “app_name”
require “.app_rc”
exit
end
:

– keiju