summaryrefslogtreecommitdiff
path: root/instruby.rb
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-01-21 08:03:05 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-01-21 08:03:05 +0000
commitff7e65eb845069ab1d865b61e6fe8a989c41c800 (patch)
tree3f11d2b2f27c0b50b1b4f1d24dcdfb5d40609bd8 /instruby.rb
parentfce7467e601e76d64a175929f2f14f89cfd450dd (diff)
* instruby.rb: use real interpreter pathname at shebang line.
[ruby-dev:19370] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'instruby.rb')
-rw-r--r--instruby.rb37
1 files changed, 23 insertions, 14 deletions
diff --git a/instruby.rb b/instruby.rb
index 89390f949a..07f7aff507 100644
--- a/instruby.rb
+++ b/instruby.rb
@@ -51,7 +51,9 @@ arc = CONFIG["LIBRUBY_A"]
makedirs [bindir, libdir, rubylibdir, archlibdir, sitelibdir, sitearchlibdir]
-install ruby_install_name+exeext, File.join(bindir, ruby_install_name+exeext), 0755
+ruby_bin = File.join(bindir, ruby_install_name)
+
+install ruby_install_name+exeext, ruby_bin+exeext, 0755
if rubyw_install_name and !rubyw_install_name.empty?
install rubyw_install_name+exeext, bindir, 0755
end
@@ -83,32 +85,39 @@ for src in Dir["bin/*"]
install src, dest, 0755
+ next if $dryrun
+
+ shebang = ''
+ body = ''
open(dest, "r+") { |f|
- shebang = f.gets.sub(/ruby/, ruby_install_name)
+ shebang = f.gets
body = f.read
- f.rewind
- f.print shebang, body
- f.truncate(f.pos)
- f.close
+ if shebang.sub!(/^\#!.*?ruby\b/) {"#!" + ruby_bin}
+ f.rewind
+ f.print shebang, body
+ f.truncate(f.pos)
+ end
+ }
- if RUBY_PLATFORM =~ /mswin32|mingw|bccwin32/
- open(dest + ".bat", "w") { |b|
- b.print <<EOH, shebang, body, <<EOF
+ if RUBY_PLATFORM =~ /mswin32|mingw|bccwin32/
+ ruby_bin_dosish = ruby_bin.gsub(Regexp.compile(File::SEPARATOR), File::ALT_SEPARATOR)
+ batfile = dest + ".bat"
+ open(batfile, "w") { |b|
+ b.print <<EOH, shebang, body, <<EOF
@echo off
if "%OS%" == "Windows_NT" goto WinNT
-ruby -Sx "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
+#{ruby_bin_dosish} -x "#{batfile}" %1 %2 %3 %4 %5 %6 %7 %8 %9
goto endofruby
:WinNT
-ruby -Sx "%~nx0" %*
+#{ruby_bin_dosish} -x "#{batfile}" %*
goto endofruby
EOH
__END__
:endofruby
EOF
- }
- end
- } unless $dryrun
+ }
+ end
end
Dir.glob("lib/**/*{.rb,help-message}") do |f|