ruby-changes:52688
From: nobu <ko1@a...>
Date: Wed, 3 Oct 2018 03:51:26 +0900 (JST)
Subject: [ruby-changes:52688] nobu:r64900 (trunk): Just a shebang is valid code
nobu 2018-10-03 03:51:21 +0900 (Wed, 03 Oct 2018) New Revision: 64900 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64900 Log: Just a shebang is valid code [ruby-core:89240] [Bug #15190] Modified files: trunk/ruby.c trunk/test/ruby/test_rubyoptions.rb Index: test/ruby/test_rubyoptions.rb =================================================================== --- test/ruby/test_rubyoptions.rb (revision 64899) +++ test/ruby/test_rubyoptions.rb (revision 64900) @@ -403,6 +403,9 @@ class TestRubyOptions < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L403 %w[4], [], bug4118) assert_ruby_status(%w[], "#! ruby -- /", '[ruby-core:82267] [Bug #13786]') + + assert_ruby_status(%w[], "#!") + assert_in_out_err(%w[-c], "#!", ["Syntax OK"]) end def test_flag_in_shebang Index: ruby.c =================================================================== --- ruby.c (revision 64899) +++ ruby.c (revision 64900) @@ -1913,11 +1913,7 @@ load_file_internal(VALUE argp_v) https://github.com/ruby/ruby/blob/trunk/ruby.c#L1913 c = rb_io_getbyte(f); if (c == INT2FIX('#')) { c = rb_io_getbyte(f); - if (c == INT2FIX('!')) { - line = rb_io_gets(f); - if (NIL_P(line)) - return 0; - + if (c == INT2FIX('!') && !NIL_P(line = rb_io_gets(f))) { RSTRING_GETMEM(line, str, len); warn_cr_in_shebang(str, len); if ((p = strstr(str, ruby_engine)) == 0) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/