Trap() with String command dosn't work(1.8/1.9)


#1

e$BF|K%3%s%H%m!<%k%7%9%F%`e(B(e$B3te(B)e$B$N6a1J$H?=$7$^$9!#e(B

e$B%%s%i%$%s%^%K%e%"%k$NNc$K$h$k$He(B Kernel#trap e$B$$h$Se(B
Signal.trap e$B$Oe(B
e$B%O%s%I%i$KJ8;zNse(B(e$B%9%/%j%W%HJRe(B)e$B$r;XDj$G$-$k$H$J$C$F$$$^$9$,!"e(B
e$B$d$C$F$_$k$H$&$^$/F0$$$F$$$J$$$h$&$G$9!#e(B

e$B%^%K%e%"%kK\J8e(B(e$B!)e(B)e$B$K$O!"%9%/%j%W%HJR$rJ8;zNs$H$7$FEO$7$F$$$$$He(B

e$B$O$C$-$j$H$O=q$$$F$J$$$h$&$G$9$1$l$Ie(B…

1.8 e$B$He(B 1.9 e$B$G$=$l$>$l0[$J$k%(%i!<FbMF$K$J$j$^$9!#e(B
e$B$J$*!"$$$m$$$m$J4D6-$G;n$7$?$N$G$9$,e(B 1.8.0 e$B$G$OF0$$$F$$$F!"e(B
1.8.1 e$B$+$iF0$+$J$/$J$C$?$h$&$G$9!#e(B

$ cat traptest.rb
Signal.trap(:INT, “p true”)
loop do
sleep
end

$ ruby-1.8.6 -v traptest.rb
ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-linux]
true # <= Ctrl-C
traptest.rb:4: unexpected return

$ ~/env/ruby-head/bin/ruby -v traptest.rb
ruby 1.9.0 (2007-01-09 patchlevel 0) [i686-linux]

<- Ctrl-C

traptest.rb:4:in sleep': wrong argument type String (expected Data) (TypeError) from traptest.rb:4:inblock in ’
from traptest.rb:3:in loop' from traptest.rb:3:in

$ ruby1.8 -v hoge.rb
ruby 1.8.0 (2003-08-10) [i386-linux]
true # <= Ctrl-C
true # <= Ctrl-C

e$B0J>e!"Js9p$@$1$G$9$_$^$;$s!#e(B


#2

e$B$J$+$@$G$9!#e(B

At Fri, 25 May 2007 19:59:48 +0900,
Chikanaga Tomoyuki wrote in [ruby-dev:30820]:

e$B%%s%i%$%s%^%K%e%"%k$NNc$K$h$k$He(B Kernel#trap e$B$$h$Se(B Signal.trap e$B$Oe(B
e$B%O%s%I%i$KJ8;zNse(B(e$B%9%/%j%W%HJRe(B)e$B$r;XDj$G$-$k$H$J$C$F$$$^$9$,!"e(B
e$B$d$C$F$_$k$H$&$^$/F0$$$F$$$J$$$h$&$G$9!#e(B

e$B%^%K%e%"%kK\J8e(B(e$B!)e(B)e$B$K$O!"%9%/%j%W%HJR$rJ8;zNs$H$7$FEO$7$F$$$$$He(B

e$B$O$C$-$j$H$O=q$$$F$J$$$h$&$G$9$1$l$Ie(B…

1.8 e$B$He(B 1.9 e$B$G$=$l$>$l0[$J$k%(%i!<FbMF$K$J$j$^$9!#e(B

1.9e$B$G$OJ8;zNs$Oe(B"DEFAULT",“IGNORE”,"EXIT"e$B$J$I0J30$OIT2D$K$J$j$^e(B
e$B$7$?!#e(B

e$B8_49@-$NOC$+$H4*0c$$$7$F$^$7$?!#e(B

$ ruby-1.8.6 -v traptest.rb
ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-linux]
true # <= Ctrl-C
traptest.rb:4: unexpected return

e$B$3$A$i$G$Oe(Btruee$B$,2L$F$7$J$/=PB3$1$^$7$?!#e(B

Index: eval.c

— eval.c (revision 12396)
+++ eval.c (working copy)
@@ -1866,5 +1866,5 @@ rb_eval_cmd(cmd, arg, level)
POP_FRAME();

  • jump_tag_but_local_jump(state, val);
  • if (state) jump_tag_but_local_jump(state, val);
    return val;
    }