[Bug #1556] irb does not save history from 1.8.7-p83 and later


#1

Bug #1556: irb does not save history from 1.8.7-p83 and later
http://redmine.ruby-lang.org/issues/show/1556

e$B5/I<<Te(B: Nobuhiro IMAI
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: Normal
ruby -v: ruby 1.8.7 (2009-01-12 patchlevel 83) [i686-linux]

1.8.7-p83 e$B0J9_e(B(p167 e$B$G$be(B)e$B!"e(Birb
e$B$,%R%9%H%j$rJ]B8$7$F$/$l$J$$$h$&$G$9!#e(B
e$B%U%!%$%J%i%$%6$,8F$P$l$k>r7o$H%?%$%_%s%0$,JQ$o$C$?1F6A$G$7$g$&$+!)e(B
e$B%A%1%C%H$rC5$7$-$l$J$+$C$?$N$G$9$,!"4{=P$@$C$?$i$4$a$s$J$5$$!#e(B

$ rm -f ~/.irb_history
$ irb -f
irb(main):001:0> require “irb/ext/save-history”
=> true
irb(main):002:0> context.save_history = 3
=> 3
irb(main):003:0> RUBY_DESCRIPTION
=> “ruby 1.8.7 (2009-01-12 patchlevel 83) [i686-linux]”
irb(main):004:0> p 83
83
=> nil
irb(main):005:0> exit
$ cat ~/.irb_history
cat: /home/nov/.irb_history: No such file or directory

p82 e$B$@$HJ]B8$5$l$^$9!#e(B

$ rm -f ~/.irb_history
$ irb -f
irb(main):001:0> require “irb/ext/save-history”
=> true
irb(main):002:0> context.save_history = 3
=> 3
irb(main):003:0> RUBY_DESCRIPTION
=> “ruby 1.8.7 (2009-01-11 patchlevel 82) [i686-linux]”
irb(main):004:0> p 82
82
=> nil
irb(main):005:0> exit
$ cat ~/.irb_history
RUBY_DESCRIPTION
p 82
exit


#2

e$B$1$$$8$e!w$$$7$D$+$G$9e(B.

ruby-1.8.7 e$B7O$N%P%0$N$h$&$J5$$,$7$^$9e(B.
e$B%U%!%$%J%i%$%6!<$,8F$S=P$5$l$Je(B
e$B$$$h$&$Je(B?

e$B2<5-$N%W%m%0%i%`$Ge(B,

obj = Object.new

def fin
proc{p 1}
end

ObjectSpace.define_finalizer(obj, fin)

#obj = nil

1.8.7e$B:G?7HG$N$%U%!%$%J%i%$%6$,<B9T$5$l$^$;$se(B. e$BB>$Ne(B, 1.8.8,
1.9e$B7O$O8Fe(B
e$B$P$l$^$9e(B. e$B$A$J$
$Ke(B obj = nil
e$B$rF~$l$k$H8F$S=P$5$l$k$N$Ge(B, e$B$=$NJU$j$NLde(B
e$BBj$G$Oe(B?

In [ruby-dev:38563] the message: “[ruby-dev:38563] [Bug #1556] irb
does not save history from 1.8.7-p83 and later”, on Jun/02 21:47(JST)
Nobuhiro IMAI writes:

=> nil
irb(main):002:0> context.save_history = 3
exit


http://redmine.ruby-lang.org

__
---------------------------------------------------->> e$B@PDMe(B
e$B7=<ye(B <<—
---------------------------------->> e-mail: removed_email_address@domain.invalid <<—


#3

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:38566] Re: [Bug #1556] irb does not save
history from 1.8.7-p83 and later”
on Thu, 4 Jun 2009 17:47:50 +0900, removed_email_address@domain.invalid
(e$B@PDM7=<ye(B) writes:

|ruby-1.8.7 e$B7O$N%P%0$N$h$&$J5$$,$7$^$9e(B. e$B%U%!%$%J%i%$%6!<$,8F$S=P$5$l$Je(B
|e$B$$$h$&$Je(B?

|1.8.7e$B:G?7HG$N$%U%!%$%J%i%$%6$,<B9T$5$l$^$;$se(B. e$BB>$Ne(B, 1.8.8, 1.9e$B7O$O8Fe(B
|e$B$P$l$^$9e(B. e$B$A$J$
$Ke(B obj = nil e$B$rF~$l$k$H8F$S=P$5$l$k$N$Ge(B, e$B$=$NJU$j$NLde(B
|e$BBj$G$Oe(B?

e$B$J$k$[$I!#D4$Y$F$_$^$9!#e(B

e$B$?$@!"%W%m%;%9=N;;~$K$$1$k%U%!%$%J%i%$%6$N?.Mj$G$-$k<B9T$Oe(B
e$B$J$+$J$+Fq$7$$$N$G!">-MhE*$K$Oe(Bhistorye$B$N%;!<%V$N$h$&$J=EMW$J%?e(B
e$B%9%/$O%U%!%$%J%i%$%6$+$i$G$O$J$/!"e(Bat_exite$B$N$h$&$J%U%C%/$G<B8=e(B
e$B$7$F$$$?$@$1$k$H=u$+$j$^$9!#e(B


#4

いまいです。

From: Yukihiro M. <matz_at_ruby-lang.org>
Date: Thu, 4 Jun 2009 18:21:02 +0900

なかなか難しいので、将来的にはhistoryのセーブのような重要なタ
スクはファイナライザからではなく、at_exitのようなフックで実現
していただけると助かります。

irb のプロセスの寿命と、obj(IRB::Context の @io)の寿命とが同じぐらいな
のであれば、単純に at_exit を使うようにするだけでいいでしょうか。今の
ところ、手元では問題なく動いています。とりあえず ruby_1_8{,_[67]} ブラ
ンチにはそのままあたると思います。


#5

e$B$1$$$8$e!w$$$7$D$+$G$9e(B.

e$B:#F|$D$D$+$l$?$N$r$b$&0l7oe(B.

In [ruby-dev:38580] the message: “[ruby-dev:38580] Re: [Bug #1556] irb
does not save history from 1.8.7-p83 and later”, on Jun/08 09:18(JST)
Nobuhiro IMAI writes:

e$B$$$^$$$G$9!#e(B

|ruby-1.8.7 e$B7O$N%P%0$N$h$&$J5$$,$7$^$9e(B. e$B%U%!%$%J%i%$%6!<$,8F$S=P$5$l$Je(B
|e$B$$$h$&$Je(B?

|1.8.7e$B:G?7HG$N$%U%!%$%J%i%$%6$,<B9T$5$l$^$;$se(B. e$BB>$Ne(B, 1.8.8, 1.9e$B7O$O8Fe(B
|e$B$P$l$^$9e(B. e$B$A$J$
$Ke(B obj = nil e$B$rF~$l$k$H8F$S=P$5$l$k$N$Ge(B, e$B$=$NJU$j$NLde(B
|e$BBj$G$Oe(B?

e$B$J$k$[$I!#D4$Y$F$_$^$9!#e(B

e$B$^$D$b$H$5$se(B, e$B$3$N7o$I$&$J$j$^$7$?e(B?
1.8.7e$B7O$N%U%!%$%J%i%$%6$N%P%0$@$H;W$C$F$$$k$N$G$9$,e(B?

e$B$=$l$H$OJL$Ke(B:

e$B$?$@!"%W%m%;%9=N;;~$K$$1$k%U%!%$%J%i%$%6$N?.Mj$G$-$k<B9T$Oe(B
e$B$J$+$J$+Fq$7$$$N$G!">-MhE*$K$Oe(Bhistorye$B$N%;!<%V$N$h$&$J=EMW$J%?e(B
e$B%9%/$O%U%!%$%J%i%$%6$+$i$G$O$J$/!"e(Bat_exite$B$N$h$&$J%U%C%/$G<B8=e(B
e$B$7$F$$$?$@$1$k$H=u$+$j$^$9!#e(B

irb e$B$N%W%m%;%9$N<wL?$H!“e(Bobj(IRB::Context e$B$Ne(B @io)e$B$N<wL?$H$,F1$8$0$i$$$Je(B
e$B$N$G$”$l$P!“C1=c$Ke(B at_exit e$B$r;H$&$h$&$K$9$k$@$1$G$$$$$G$7$g$&$+!#:#$Ne(B
e$B$H$3$m!”<j85$G$OLdBj$J$/F0$$$F$$$^$9!#$H$j$"$($:e(B ruby_1_8{,_[67]} e$B%V%ie(B
e$B%s%A$K$O$=$N$^$^$"$?$k$H;W$$$^$9!#e(B

e$B$3$l$O$3$l$G$=$NDL$j$@$H;W$$$^$9$N$Ge(B, e$B:NMQ$7$?$$$H;W$$$^$9e(B.

__
---------------------------------------------------->> e$B@PDMe(B
e$B7=<ye(B <<—
---------------------------------->> e-mail: removed_email_address@domain.invalid <<—


#6

e$B$1$$$8$e!w$$$7$D$+$G$9e(B.

In [ruby-dev:38819] the message: “[ruby-dev:38819] Re: [Bug #1556] irb
does not save history from 1.8.7-p83 and later”, on Jul/18 01:43(JST)
Yukihiro M. writes:

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

e$B%U%!%$%J%i%$%6$N%P%0$J$N$O3N$+$G$9!#$?$@$7!"%U%!%$%J%i%$%6$re(B
e$BI,$:8F$V$N$O$+$J$j:$Fq$J$N$G!"e(Bat_exite$B$G$NBP1~$r$*4j$$$7$?$$e(B
e$B$H$3$m$G$9!#$h$m$7$/!#e(B

at_exite$B$@$He(B, e$BAH$_9~$^$l$F$$$k$H$-$KBP1~$G$-$J$$$N$Ge(B,
irbe$B$+$iH4$1$?$H$-e(B
e$B$K<B9T$9$k$h$&$K$7$^$7$?e(B.

e$B$=$l$Ge(B, trunke$B$NJ}$K$OH?1G$7$^$7$?$,e(B,
1.8.7e$B$X$NH?1G$O$I$&$9$l$P$h$$$s$Ge(B
e$B$7$g$&e(B? e$B2?$+<jB3$-$H$+$"$j$^$9e(B?

__
---------------------------------------------------->> e$B@PDMe(B
e$B7=<ye(B <<—
---------------------------------->> e-mail: removed_email_address@domain.invalid <<—


#7

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:38818] Re: [Bug #1556] irb does not save
history from 1.8.7-p83 and later”
on Sat, 18 Jul 2009 01:08:03 +0900, removed_email_address@domain.invalid (keiju
ISHITSUKA) writes:

|>> e$B$J$k$[$I!#D4$Y$F$_$^$9!#e(B
|
|e$B$^$D$b$H$5$se(B, e$B$3$N7o$I$&$J$j$^$7$?e(B?
|1.8.7e$B7O$N%U%!%$%J%i%$%6$N%P%0$@$H;W$C$F$$$k$N$G$9$,e(B?

e$B%U%!%$%J%i%$%6$N%P%0$J$N$O3N$+$G$9!#$?$@$7!"%U%!%$%J%i%$%6$re(B
e$BI,$:8F$V$N$O$+$J$j:$Fq$J$N$G!"e(Bat_exite$B$G$NBP1~$r$*4j$$$7$?$$e(B
e$B$H$3$m$G$9!#$h$m$7$/!#e(B


#8

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:38839] Re: [Bug #1556] irb does not save
history from 1.8.7-p83 and later”
on Wed, 22 Jul 2009 00:42:09 +0900, removed_email_address@domain.invalid
(e$B@PDM7=<ye(B) writes:

|e$B$=$l$Ge(B, trunke$B$NJ}$K$OH?1G$7$^$7$?$,e(B, 1.8.7e$B$X$NH?1G$O$I$&$9$l$P$h$$$s$Ge(B
|e$B$7$g$&e(B? e$B2?$+<jB3$-$H$+$"$j$^$9e(B?

1.8 HEADe$B$KFM$C9~$s$G$/$@$5$$!#3F%V%i%s%A$N%a%s%F%J$,%P%C%/%]!<e(B
e$B%H$9$k$G$7$g$&!#e(B


#9

e$B$$$^$$$G$9!#e(B

From: keiju_at_ishitsuka.com (e$B@PDM7=<ye(B)
Date: Wed, 22 Jul 2009 00:42:09 +0900

at_exite$B$@$He(B, e$BAH$_9~$^$l$F$$$k$H$-$KBP1~$G$-$J$$$N$Ge(B, irbe$B$+$iH4$1$?$H$-e(B
e$B$K<B9T$9$k$h$&$K$7$^$7$?e(B.

lib/irb.rb e$B$,99?7$5$l$F$$$J$$$h$&$G$9!#e(B

$ svn log -v -r24229

r24229 | keiju | 2009-07-22 00:39:51 +0900 (Wed, 22 Jul 2009) | 4 lines
Changed paths:
M /trunk/ChangeLog
M /trunk/lib/irb/ext/save-history.rb
M /trunk/lib/irb/init.rb

  • lib/irb.rb, lib/irb/init.rb, lib/irb/ext/save-history.rb: add
    IRB::irb_at_exit. no use finalizer saving history. [ruby-dev-38563]

$ svn log -l1 lib/irb.rb

r23985 | keiju | 2009-07-07 20:36:20 +0900 (Tue, 07 Jul 2009) | 3 lines

  • bin/irb, lib/irb.rb lib/irb/*: irb-0.9.6, extend inspect-mode

#10

チケット #1556 が更新されました。 (by Shyouhei U.)

ステータス OpenからClosedに変更

Fixed in 1.8.7-p196.


#11

e$B$1$$$8$e!w$$$7$D$+$G$9e(B.

In [ruby-dev:38841] the message: “[ruby-dev:38841] Re: [Bug #1556] irb
does not save history from 1.8.7-p83 and later”, on Jul/22 01:49(JST)
Nobuhiro IMAI writes:

e$B$$$^$$$G$9!#e(B

at_exite$B$@$He(B, e$BAH$_9~$^$l$F$$$k$H$-$KBP1~$G$-$J$$$N$Ge(B, irbe$B$+$iH4$1$?$H$-e(B
e$B$K<B9T$9$k$h$&$K$7$^$7$?e(B.

lib/irb.rb e$B$,99?7$5$l$F$$$J$$$h$&$G$9!#e(B

e$B?=$7Lu$J$$e(B. e$BDI2C$7$^$7$?e(B.

__
---------------------------------------------------->> e$B@PDMe(B
e$B7=<ye(B <<—
---------------------------------->> e-mail: removed_email_address@domain.invalid <<—