diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2021-11-04 20:31:06 +0100 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2021-11-05 23:20:47 +0900 |
commit | 5b941ec90dd76ddb78a3c9e5179f3eee801b4036 (patch) | |
tree | 855841ef42c081b8ef069fb5fe16ae83d62e906d /lib/rubygems/commands | |
parent | 56119c5245ac4fa8d7c22de584a226b44082f61e (diff) |
[rubygems/rubygems] Remove unnecessary loop
Rubygems installs a single executable. Make that explicit.
https://github.com/rubygems/rubygems/commit/2839d15521
Diffstat (limited to 'lib/rubygems/commands')
-rw-r--r-- | lib/rubygems/commands/setup_command.rb | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb index edc4008cb8..dd4771b7b9 100644 --- a/lib/rubygems/commands/setup_command.rb +++ b/lib/rubygems/commands/setup_command.rb @@ -257,35 +257,32 @@ By default, this RubyGems will install gem as: say "Installing #{tool} executable" if @verbose Dir.chdir path do - bin_files = Dir['*'] + bin_file = "gem" - bin_files -= %w[update_rubygems] + dest_file = target_bin_path(bin_dir, bin_file) + bin_tmp_file = File.join Dir.tmpdir, "#{bin_file}.#{$$}" - bin_files.each do |bin_file| - dest_file = target_bin_path(bin_dir, bin_file) - bin_tmp_file = File.join Dir.tmpdir, "#{bin_file}.#{$$}" + begin + bin = File.readlines bin_file + bin[0] = shebang - begin - bin = File.readlines bin_file - bin[0] = shebang - - File.open bin_tmp_file, 'w' do |fp| - fp.puts bin.join - end - - install bin_tmp_file, dest_file, :mode => prog_mode - bin_file_names << dest_file - ensure - rm bin_tmp_file + File.open bin_tmp_file, 'w' do |fp| + fp.puts bin.join end - next unless Gem.win_platform? + install bin_tmp_file, dest_file, :mode => prog_mode + bin_file_names << dest_file + ensure + rm bin_tmp_file + end + + next unless Gem.win_platform? - begin - bin_cmd_file = File.join Dir.tmpdir, "#{bin_file}.bat" + begin + bin_cmd_file = File.join Dir.tmpdir, "#{bin_file}.bat" - File.open bin_cmd_file, 'w' do |file| - file.puts <<-TEXT + File.open bin_cmd_file, 'w' do |file| + file.puts <<-TEXT @ECHO OFF IF NOT "%~f0" == "~f0" GOTO :WinNT @"#{File.basename(Gem.ruby).chomp('"')}" "#{dest_file}" %1 %2 %3 %4 %5 %6 %7 %8 %9 @@ -293,12 +290,11 @@ By default, this RubyGems will install gem as: :WinNT @"#{File.basename(Gem.ruby).chomp('"')}" "%~dpn0" %* TEXT - end - - install bin_cmd_file, "#{dest_file}.bat", :mode => prog_mode - ensure - rm bin_cmd_file end + + install bin_cmd_file, "#{dest_file}.bat", :mode => prog_mode + ensure + rm bin_cmd_file end end end |