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
This commit is contained in:
parent
6881279149
commit
157ee2bdbc
6
ruby.c
6
ruby.c
@ -731,11 +731,11 @@ moreswitches(const char *s, ruby_cmdline_options_t *opt, int envopt)
|
|||||||
|
|
||||||
while (ISSPACE(*s)) s++;
|
while (ISSPACE(*s)) s++;
|
||||||
if (!*s) return;
|
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);
|
argary = rb_str_tmp_new(0);
|
||||||
|
|
||||||
p = RSTRING_PTR(argstr);
|
p = RSTRING_PTR(argstr);
|
||||||
*p++ = ' ';
|
if (envopt) *p++ = ' ';
|
||||||
memcpy(p, s, len + 1);
|
memcpy(p, s, len + 1);
|
||||||
ap = 0;
|
ap = 0;
|
||||||
rb_str_cat(argary, (char *)&ap, sizeof(ap));
|
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));
|
rb_str_cat(argary, (char *)&ap, sizeof(ap));
|
||||||
argv = (char **)RSTRING_PTR(argary);
|
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;
|
argv += i;
|
||||||
if (**argv != '-') {
|
if (**argv != '-') {
|
||||||
*--*argv = '-';
|
*--*argv = '-';
|
||||||
|
@ -338,6 +338,8 @@ class TestRubyOptions < Test::Unit::TestCase
|
|||||||
%w[4], [], bug4118)
|
%w[4], [], bug4118)
|
||||||
assert_in_out_err(%w[-x], "#!/bin/sh\n""#!shebang\n""#!ruby\n""puts __LINE__\n",
|
assert_in_out_err(%w[-x], "#!/bin/sh\n""#!shebang\n""#!ruby\n""puts __LINE__\n",
|
||||||
%w[4], [], bug4118)
|
%w[4], [], bug4118)
|
||||||
|
|
||||||
|
assert_ruby_status(%w[], "#! ruby -- /", '[ruby-core:82267] [Bug #13786]')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_sflag
|
def test_sflag
|
||||||
|
Loading…
x
Reference in New Issue
Block a user