merge revision(s) 64900: [Backport #15190]

Just a shebang is valid code

	[ruby-core:89240] [Bug #15190]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@64980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagachika 2018-10-09 14:25:37 +00:00
parent b014387f68
commit 98eb63a896
3 changed files with 5 additions and 6 deletions

6
ruby.c
View file

@ -1836,11 +1836,7 @@ load_file_internal(VALUE argp_v)
c = rb_io_getbyte(f); c = rb_io_getbyte(f);
if (c == INT2FIX('#')) { if (c == INT2FIX('#')) {
c = rb_io_getbyte(f); c = rb_io_getbyte(f);
if (c == INT2FIX('!')) { if (c == INT2FIX('!') && !NIL_P(line = rb_io_gets(f))) {
line = rb_io_gets(f);
if (NIL_P(line))
return 0;
RSTRING_GETMEM(line, str, len); RSTRING_GETMEM(line, str, len);
warn_cr_in_shebang(str, len); warn_cr_in_shebang(str, len);
if ((p = strstr(str, ruby_engine)) == 0) { if ((p = strstr(str, ruby_engine)) == 0) {

View file

@ -344,6 +344,9 @@ class TestRubyOptions < Test::Unit::TestCase
%w[4], [], bug4118) %w[4], [], bug4118)
assert_ruby_status(%w[], "#! ruby -- /", '[ruby-core:82267] [Bug #13786]') assert_ruby_status(%w[], "#! ruby -- /", '[ruby-core:82267] [Bug #13786]')
assert_ruby_status(%w[], "#!")
assert_in_out_err(%w[-c], "#!", ["Syntax OK"])
end end
def test_flag_in_shebang def test_flag_in_shebang

View file

@ -1,6 +1,6 @@
#define RUBY_VERSION "2.5.2" #define RUBY_VERSION "2.5.2"
#define RUBY_RELEASE_DATE "2018-10-09" #define RUBY_RELEASE_DATE "2018-10-09"
#define RUBY_PATCHLEVEL 93 #define RUBY_PATCHLEVEL 94
#define RUBY_RELEASE_YEAR 2018 #define RUBY_RELEASE_YEAR 2018
#define RUBY_RELEASE_MONTH 10 #define RUBY_RELEASE_MONTH 10