aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems/installer.rb
diff options
context:
space:
mode:
authorOlle Jonsson <olle.jonsson@auctionet.com>2020-04-19 22:39:42 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-06-05 07:32:42 +0900
commit5eacf4e72cffadde3c4c2b6dada6cd5343310ae3 (patch)
treee5e98963fa1a51886eaea7ba84201e05ee545e83 /lib/rubygems/installer.rb
parentf8f5e7fadf689a11a8ee28b7af4e7777e2dec1ea (diff)
downloadruby-5eacf4e72cffadde3c4c2b6dada6cd5343310ae3.tar.gz
Enable rubocop-performance StartWith cop
- this would keep the could-be-a-string-method matches few
Diffstat (limited to 'lib/rubygems/installer.rb')
-rw-r--r--lib/rubygems/installer.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index cf676854dc..92e6126ada 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -584,9 +584,9 @@ class Gem::Installer
def shebang(bin_file_name)
ruby_name = RbConfig::CONFIG['ruby_install_name'] if @env_shebang
path = File.join gem_dir, spec.bindir, bin_file_name
- first_line = File.open(path, "rb") {|file| file.gets}
+ first_line = File.open(path, "rb") {|file| file.gets} || ""
- if /\A#!/ =~ first_line
+ if first_line.start_with?("#!")
# Preserve extra words on shebang line, like "-w". Thanks RPA.
shebang = first_line.sub(/\A\#!.*?ruby\S*((\s+\S+)+)/, "#!#{Gem.ruby}")
opts = $1