diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-08-10 05:54:56 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-08-10 05:54:56 +0000 |
commit | 39de088e8860b55443962ab7f31efe94a766f50c (patch) | |
tree | 7570b081f3d64fdb5c3b6cb7d3e56339d48c0cc5 /ruby.c | |
parent | b4933f2a66baecf8abe4ecd4020ee7d042c1eea4 (diff) | |
download | ruby-39de088e8860b55443962ab7f31efe94a766f50c.tar.gz |
ruby.c: ignore non-option in shebang line
* ruby.c (moreswitches): process all words as options only in
an environment variable, but not in a shebang line.
[ruby-core:82267] [Bug #13786]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r-- | ruby.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -731,11 +731,11 @@ moreswitches(const char *s, ruby_cmdline_options_t *opt, int envopt) while (ISSPACE(*s)) s++; if (!*s) return; - argstr = rb_str_tmp_new((len = strlen(s)) + 2); + argstr = rb_str_tmp_new((len = strlen(s)) + (envopt!=0)); argary = rb_str_tmp_new(0); p = RSTRING_PTR(argstr); - *p++ = ' '; + if (envopt) *p++ = ' '; memcpy(p, s, len + 1); ap = 0; rb_str_cat(argary, (char *)&ap, sizeof(ap)); @@ -752,7 +752,7 @@ moreswitches(const char *s, ruby_cmdline_options_t *opt, int envopt) rb_str_cat(argary, (char *)&ap, sizeof(ap)); argv = (char **)RSTRING_PTR(argary); - while ((i = proc_options(argc, argv, opt, envopt)) > 1 && (argc -= i) > 0) { + while ((i = proc_options(argc, argv, opt, envopt)) > 1 && envopt && (argc -= i) > 0) { argv += i; if (**argv != '-') { *--*argv = '-'; |