nobu.nokada
1/15/2005 5:40:00 AM
Hi,
At Sat, 15 Jan 2005 06:15:33 +0900,
Nicholas Van Weerdenburg wrote in [ruby-talk:126498]:
> I guess my question might be better phrased "why doesn't running the
> ruby interpreter with no input not default to interactive mode (irb)
> such as with the python interpreter".
>
> I'm mostly curious for no practical reason. Just wondering if there is
> functionality or design benefits.
It's in the ToDo list.
* Built-in Interactive Ruby.
Index: ruby.c
===================================================================
RCS file: /cvs/ruby/src/ruby/ruby.c,v
retrieving revision 1.94
diff -U2 -p -r1.94 ruby.c
--- ruby.c 24 Sep 2004 05:53:41 -0000 1.94
+++ ruby.c 15 Jan 2005 05:34:34 -0000
@@ -782,5 +782,15 @@ proc_options(argc, argv)
}
else if (strlen(script) == 1 && script[0] == '-') {
- load_stdin();
+ if (!do_check && !do_loop && isatty(0) && isatty(1) && isatty(2) &&
+ !NIL_P(rb_rescue2(rb_require, (VALUE)"irb",
+ (VALUE (*)())0, (VALUE)0,
+ rb_eLoadError, (VALUE)0))) {
+ require_libraries();
+ ruby_eval_tree = NEW_CALL(NEW_LIT(rb_const_get(rb_cObject, rb_intern("IRB"))),
+ rb_intern("start"), 0);
+ }
+ else {
+ load_stdin();
+ }
}
else {
--
Nobu Nakada