tags:

views:

80

answers:

2

ruby -n is the closest thing I found, but it repeats the whole script. Also it's not available for irb.

+1  A: 
$ cat > hello.rb
$hello = 'Hello, world!'
puts $hello
^D
$ irb
irb(main):001:0> load 'hello.rb'
Hello, world!
=> true
irb(main):002:0> $hello
=> "Hello, world!"

A bit tedious, and local variables won't carry through. May be close enough for your usage? (This is basically like Python's execfile.)

ephemient
+1  A: 

irb -r hello.rb

banister