From 1d36a09d81d3b1b06902942fc912fa9cf8ddd5ad Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 15 Jan 2017 05:50:41 +0000 Subject: [PATCH] rbinstall.rb: mimic rubygems wrapper script * tool/rbinstall.rb (app_script_text): move shell script part after comments generated by RubyGems. '#'-lines are comments in both of ruby and shell script. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- tool/rbinstall.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb index 490f5f3281..854fa07e14 100755 --- a/tool/rbinstall.rb +++ b/tool/rbinstall.rb @@ -693,7 +693,16 @@ module RbInstall def shebang(bin_file_name) path = File.join(gem_dir, spec.bindir, bin_file_name) first_line = File.open(path, "rb") {|file| file.gets} - $script_installer.prolog(first_line) + $script_installer.prolog(first_line).chomp + end + + def app_script_text(bin_file_name) + # move shell script part after comments generated by RubyGems. + super.sub(/\A + (\#!\/bin\/sh\n\#.*-\*-\s*ruby\s*-\*-.*\n) + ((?:.*\n)*?\#!.*ruby.*\n) + \#\n + ((?:\#.*\n)+)/x, '\1\3\2') end def check_executable_overwrite(filename)