aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ruby.c6
-rw-r--r--test/ruby/test_rubyoptions.rb3
2 files changed, 4 insertions, 5 deletions
diff --git a/ruby.c b/ruby.c
index a5464e1a0a..a72a5dfb32 100644
--- a/ruby.c
+++ b/ruby.c
@@ -1913,11 +1913,7 @@ load_file_internal(VALUE argp_v)
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) {
diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb
index 371bfd5519..1417541282 100644
--- a/test/ruby/test_rubyoptions.rb
+++ b/test/ruby/test_rubyoptions.rb
@@ -403,6 +403,9 @@ class TestRubyOptions < Test::Unit::TestCase
%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