Forum: Ruby load "/proc/self/fd/#{$stdin.fileno}"

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Thomas H. (Guest)
on 2009-04-19 04:00
(Received via mailing list)

the Ruby code in this article's subject works for my machine running
Ubuntu Linux, but I don't expect it to work for different operating
systems (NetBSD, FreeBSD a.s.o.).

How can alternative OS independent Ruby code look like? Of course, it
shall also load from standard input rather than from a file. Despite
that, it shall be very close to loading a "real" file, e.g.: the line
number of the error location shall be told in case of a syntax error
within the loaded code.

David Rio (Guest)
on 2009-04-19 04:40
(Received via mailing list)
On Sat, Apr 18, 2009 at 7:00 PM, Thomas H.
<removed_email_address@domain.invalid> wrote:
> within the loaded code.
$ cat foo.rb
eval $
$ echo "puts 'this is great' "| ruby ./foo.rb
this is great
Joel VanderWerf (Guest)
on 2009-04-20 23:33
(Received via mailing list)
Thomas H. wrote:
> within the loaded code.
Use #read and #eval instead of #load, and supply the file/line params to

$ cat bar.rb
puts "in bar"

$ cat foo.rb
file = "bar.rb"

data =

eval data, nil, "your text here", 0

$ ruby foo.rb
in bar
your text here:2: undefined local variable or method
`xfndksnf_syntax_error' for main:Object (NameError)
Thomas H. (Guest)
on 2009-04-23 02:11
(Received via mailing list)
Thanks to David and Joel!

This topic is locked and can not be replied to.