From: Dale Martenson Date: 2006-06-22T06:18:43+09:00 Subject: Re: How to do this debugging? Philip Rhoades wrote: > Dale, > > Something odd here - see below . . > > > On Tue, 2006-06-20 at 23:54 +0900, Dale Martenson wrote: >> >> >> > Debug.rb >> > . >> > require 'ftools' (line 6) >> you could share the source. Or could you reduce the program down to a >> prefix. The input is just the program source itself. >> puts "BUBBA END." >> >> /usr/lib/ruby/1.8/ftools.rb:15: def syscopy from, to >> (rdb:1) s >> /usr/lib/ruby/1.8/ftools.rb:150: alias o_chmod chmod >> d.rb:5:$stdin.each_line do |line| >> d.rb:6: puts "BUBBA: "+line >> BUBBA: end >> You should attempt to step through your program to see what happens. You >> may want to turn on trace. > > > [root@prix bin]# ruby -r debug debugtst.rb > Debug.rb > Emacs support available. > > debugtst.rb:3:require 'ftools' > (rdb:1) $stdin = IO.popen( "cat debugtst.rb" ) > # > (rdb:1) #!/usr/bin/env ruby > nil > (rdb:1) > #!/usr/bin/env ruby > nil > (rdb:1) require 'ftools' > true > (rdb:1) > require 'ftools' > false > (rdb:1) $stdin.each_line do |line| > debugtst.rb:3:compile error > debugtst.rb:3: syntax error, unexpected $end > $stdin.each_line do |line| > ^ > (rdb:1) puts "BUBBA: "+line > debugtst.rb:3:undefined local variable or method `line' for main:Object > (rdb:1) end > debugtst.rb:3:compile error > debugtst.rb:3: syntax error, unexpected kEND > (rdb:1) puts "BUBBA END." > BUBBA END. > nil > (rdb:1) > puts "BUBBA END." > BUBBA END. > nil > (rdb:1) > puts "BUBBA END." > BUBBA END. > nil > (rdb:1) > puts "BUBBA END." > BUBBA END. > nil > (rdb:1) > > > I don't get the chance to step . . it looks like something peculiar to > my system (FC5 + latest Ruby) . . any idea what? > What version of ruby are you using? I happened to be using 1.8.2 (not the latest and greatest, but darn good none the less). It is like it is not letting you redefine $stdin. Once you do, it takes the input to the debugger from the piped input which is not what you want. Is this a difference between using readline or not for IRB. I don't think so and I would assume you are using readline for IRB. I also tried it on an older machine of mine that is running a 1.8.1 version of Ruby that doesn't have readline and it worked as I would expect. Weird? --Dale -- Posted via http://www.ruby-forum.com/.