Permalink
Browse files

Add ConsoleInterp with a ruby_eval command for script/console

git-svn-id: svn://rubyforge.org/var/svn/tcl/trunk@9 017b7ecb-b1d0-4998-98d6-e9014aaf4887
  • Loading branch information...
1 parent 05780f0 commit fe5c3e6a6a53ba79c4823db4deddc0a0ddce44b6 @sstephenson sstephenson committed Dec 7, 2007
Showing with 24 additions and 2 deletions.
  1. +2 −0 TODO
  2. +22 −2 script/console
View
2 TODO
@@ -1 +1,3 @@
* Tcl::Interp#to_tcl should account for interpreter aliases (see http://wiki.tcl.tk/8766) and namespaces.
+
+* ConsoleInterp#exit crashes with "DeleteInterpProc called with active evals".
View
@@ -2,12 +2,32 @@
require File.join(File.dirname(__FILE__), *%w".. lib tcl")
+class ConsoleInterp < Tcl::Interp
+ def initialize
+ super
+ expose :exit
+ expose :ruby_eval
+ end
+
+ def tcl_ruby_eval(script)
+ Kernel.eval(script)
+ end
+
+ def tcl_exit
+ exit
+ end
+
+ protected
+ def expose(name)
+ _!(:interp, :alias, nil, name, nil, :interp_send, name)
+ end
+end
+
filename = ARGV.shift || File.join(File.dirname(__FILE__), *%w".. .state.dat")
-interp = Tcl::Interp.load_from_file(filename) rescue Tcl::Interp.new
+interp = ConsoleInterp.load_from_file(filename) rescue ConsoleInterp.new
script = ""
at_exit do
- # FIXME This is not fired when you call "exit" from Tcl
File.open(filename, "w") do |file|
file.write(interp.to_tcl)
end

0 comments on commit fe5c3e6

Please sign in to comment.