diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | process.c | 6 |
2 files changed, 8 insertions, 2 deletions
@@ -1,3 +1,7 @@ +Tue Jun 5 19:21:10 2012 Tanaka Akira <akr@fsij.org> + + * process.c (rb_exec_fillarg): bail out a loop eagerly. + Tue Jun 5 19:15:14 2012 Tanaka Akira <akr@fsij.org> * process.c: add comments about async-signal-safe. @@ -1805,10 +1805,12 @@ rb_exec_fillarg(VALUE prog, int argc, VALUE *argv, VALUE env, VALUE opthash, str int has_meta = 0; int has_nonspace = 0; for (p = RSTRING_PTR(prog); *p; p++) { - if (*p != ' ' && *p != '\t') + if (!has_nonspace && *p != ' ' && *p != '\t') has_nonspace = 1; - if (strchr("*?{}[]<>()~&|\\$;'`\"\n", *p)) + if (!has_meta && strchr("*?{}[]<>()~&|\\$;'`\"\n", *p)) has_meta = 1; + if (has_nonspace && has_meta) + break; } if (has_nonspace && !has_meta) { /* avoid shell since no shell meta charactor found. */ |