Skip to content
Permalink
Browse files
Allow true/false argument to Kernel#exit
  • Loading branch information
shuujii committed Nov 22, 2019
1 parent 1bb1df1 commit d81e4d71c17f9d65ea87f0e66a4338411863f7bf
Showing 1 changed file with 9 additions and 4 deletions.
@@ -4,12 +4,17 @@
static mrb_value
f_exit(mrb_state *mrb, mrb_value self)
{
mrb_int i = EXIT_SUCCESS;
mrb_value status = mrb_true_value();
int istatus;

mrb_get_args(mrb, "|o", &status);
istatus = mrb_true_p(status) ? EXIT_SUCCESS :
mrb_false_p(status) ? EXIT_FAILURE :
(int)mrb_int(mrb, status);
exit(istatus);

mrb_get_args(mrb, "|i", &i);
exit((int)i);
/* not reached */
return mrb_nil_value();
return status;
}

void

0 comments on commit d81e4d7

Please sign in to comment.