pass ARGV to main.rb; catch bootstrapping exceptions

This commit is contained in:
Josh Holtrop 2014-07-12 10:30:02 -04:00
parent f0db52e3d7
commit 2d7d3d14ab
2 changed files with 16 additions and 5 deletions

View File

@ -1 +1,6 @@
def main
puts "hi from main.rb"
p ARGV
end
main

View File

@ -6,6 +6,14 @@ using namespace std;
RUBY_GLOBAL_SETUP
static void handle_bootstrap_error()
{
VALUE e = rb_errinfo();
VALUE s = rb_funcall(e, rb_intern("message"), 0);
fprintf(stderr, "%s\n", StringValueCStr(s));
rb_set_errinfo(Qnil);
}
static int bootstrap()
{
int rv = 0;
@ -15,10 +23,7 @@ static int bootstrap()
&err_state);
if (err_state != 0)
{
VALUE e = rb_errinfo();
VALUE s = rb_funcall(e, rb_intern("message"), 0);
fprintf(stderr, "%s\n", StringValueCStr(s));
rb_set_errinfo(Qnil);
handle_bootstrap_error();
rv = 1;
}
return rv;
@ -37,6 +42,7 @@ int main(int argc, char *argv[])
ruby_init();
ruby_init_loadpath();
ruby_script(argv[0]);
ruby_set_argv(argc, argv);
rv = bootstrap();
ruby_finalize();
}