Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Do not run node if node is not executable. (Backport from 1.9)

 - Fixes #592



git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@4200 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information...
commit 6d62a32050420bedeb1479cfa65aa1d2cd4a72f0 1 parent ede7861
Thibault Martin-Lagardette authored
Showing with 29 additions and 8 deletions.
  1. +29 −8 eval.c
View
37 eval.c
@@ -189,18 +189,39 @@ extern VALUE rb_progname;
void rb_require_libraries(void);
int
-ruby_run_node(void *n)
+ruby_executable_node(void *n, int *status)
{
- rb_require_libraries();
- if ((VALUE)n == Qtrue) {
- return EXIT_SUCCESS;
+ VALUE v = (VALUE)n;
+ int s;
+
+ switch (v) {
+ case Qtrue:
+ s = EXIT_SUCCESS;
+ break;
+ case Qfalse:
+ s = EXIT_FAILURE;
+ break;
+ default:
+ if (!FIXNUM_P(v)) {
+ return TRUE;
+ }
+ s = FIX2INT(v);
}
- else if ((VALUE)n == Qfalse) {
- return EXIT_FAILURE;
+ if (status) {
+ *status = s;
}
- else if (FIXNUM_P(n)) {
- return FIX2INT(n);
+ return FALSE;
+}
+
+int
+ruby_run_node(void *n)
+{
+ int status;
+ if (!ruby_executable_node(n, &status)) {
+ ruby_cleanup(0);
+ return status;
}
+ rb_require_libraries();
rb_vm_run(RSTRING_PTR(rb_progname), (NODE *)n, NULL, false);
return ruby_cleanup(0);
}
Please sign in to comment.
Something went wrong with that request. Please try again.