pass ARGV to main.rb; catch bootstrapping exceptions

This commit is contained in:
josh committed 2014-07-12 10:30:02 -04:00
1 parent f0db52e3d7
commit 2d7d3d14ab
2 files changed
+15 -4

No files matched your search

+5
View File
@@ -1 +1,6 @@
def main
puts "hi from main.rb" puts "hi from main.rb"
p ARGV
end
main
+10 -4
View File
@@ -6,6 +6,14 @@ using namespace std;
RUBY_GLOBAL_SETUP 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() static int bootstrap()
{ {
int rv = 0; int rv = 0;
@@ -15,10 +23,7 @@ static int bootstrap()
&err_state); &err_state);
if (err_state != 0) if (err_state != 0)
{ {
VALUE e = rb_errinfo(); handle_bootstrap_error();
VALUE s = rb_funcall(e, rb_intern("message"), 0);
fprintf(stderr, "%s\n", StringValueCStr(s));
rb_set_errinfo(Qnil);
rv = 1; rv = 1;
} }
return rv; return rv;
@@ -37,6 +42,7 @@ int main(int argc, char *argv[])
ruby_init(); ruby_init();
ruby_init_loadpath(); ruby_init_loadpath();
ruby_script(argv[0]); ruby_script(argv[0]);
ruby_set_argv(argc, argv);
rv = bootstrap(); rv = bootstrap();
ruby_finalize(); ruby_finalize();
} }