From 6a16d03365a565cbf22f148e997dca55d63cb00b Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 13 Oct 2017 01:26:51 +0000 Subject: [PATCH] rbinstall.rb: fix for --cmd-type=cmd * tool/rbinstall.rb (PROLOG_SCRIPT): fix wrapper code for cmd script. [Bug#13997] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60174 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- tool/rbinstall.rb | 60 +++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb index 93aed570b7..6db660dc19 100755 --- a/tool/rbinstall.rb +++ b/tool/rbinstall.rb @@ -426,26 +426,36 @@ install?(:doc, :capi) do install_recursive "doc/capi", docdir+"/capi", :mode => $data_mode end -if load_relative or /\s/ =~ bindir - PROLOG_SCRIPT = < %q<-*- ruby -*- +@"%~dp0#{ruby_install_name}" -x "%~f0" %* +@exit /b %ERRORLEVEL% +};{#\n#{prolog_script.gsub(/(?=\n)/, ' #')}>,\n} +EOS +PROLOG_SCRIPT.default = (load_relative || /\s/ =~ bindir) ? + <,\n}\n" - postbatch.gsub!(/(?=\n)/, ' #') def prolog(shebang) - if PROLOG_SCRIPT and !$cmdtype - shebang.sub!(/\A(\#!.*?ruby\b)?/) {PROLOG_SCRIPT + ($1 || "#!ruby\n")} - else - shebang.sub!(/\A(\#!.*?ruby\b)?/) {"#!" + ruby_shebang + ($1 ? "" : "\n")} - end shebang.sub!(/\r$/, '') + script = PROLOG_SCRIPT[$cmdtype] + shebang.sub!(/\A(\#!.*?ruby\b)?/) do + if script.end_with?("\n") + script + ($1 || "#!ruby\n") + else + $1 ? script : "#{script}\n" + end + end shebang end @@ -507,18 +516,13 @@ $script_installer = Struct.new(:ruby_shebang, :ruby_bin, :ruby_install_name, case $cmdtype when "exe" stub + shebang + body - when "cmd" - prebatch + <<"/EOH" << postbatch << shebang << body -@"%~dp0#{ruby_install_name}" -x "%~f0" %* -@exit /b %ERRORLEVEL% -/EOH else shebang + body end end end - break new(ruby_shebang, ruby_bin, ruby_install_name, stub, trans, prebatch, postbatch) + break new(ruby_shebang, ruby_bin, ruby_install_name, stub, trans) end install?(:local, :comm, :bin, :'bin-comm') do