Sha256: f34f576bced8ddc82daa57ad5d54ca40bc162bd5f72260a3c1709cfe27b8f7d5

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

#!/usr/bin/env ruby
root = File.expand_path('../..', __FILE__)
lib_path = File.join(root, 'lib')
$LOAD_PATH << lib_path unless $LOAD_PATH.include? lib_path
require 'shen_ruby'

# Leave gracefully if someone hits Control-C during loading
Signal.trap("INT") { puts "\nLeaving..."; exit 1 }

# Load the Shen Envinronment
print "Loading..."
STDOUT.flush
start = Time.now.to_f
shen = ShenRuby::Shen.new
now = Time.now.to_f
puts ". Completed in %0.2f seconds.\n" % (now - start)

# Now that the Shen environment is loaded, repurpose the SIGINT
# handler to interrupt the current execution. Subclass Interrupt
# so that the exception is not caught by trap-error.
class ReplInterrupt < Interrupt; end
Signal.trap("INT") { raise ReplInterrupt }

# Launch the REPL
command = :"shen.shen"
begin
  shen.__send__ command
rescue ReplInterrupt, SystemStackError => e
  if e.kind_of? ReplInterrupt
    puts "Execution interrupted. If you are trying to exit the REPL, use (quit)."
  else
    puts "Stack overflow"
  end
  command = :"shen.loop"
  retry
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
shen-ruby-0.15.1 bin/srrepl
shen-ruby-0.15.0 bin/srrepl
shen-ruby-0.14.0 bin/srrepl
shen-ruby-0.13.0 bin/srrepl