[rubygems/rubygems] Autoload shellwords when it's needed.

https://github.com/rubygems/rubygems/commit/e916ccb2d9
This commit is contained in:
Samuel Williams 2023-06-09 22:10:56 +09:00 committed by git
parent c74f42a4fb
commit 27b07776c9
4 changed files with 11 additions and 8 deletions

View File

@ -7,6 +7,7 @@
#++ #++
require_relative "../user_interaction" require_relative "../user_interaction"
require_relative "../shellwords"
class Gem::Ext::Builder class Gem::Ext::Builder
include Gem::UserInteraction include Gem::UserInteraction
@ -55,9 +56,8 @@ class Gem::Ext::Builder
end end
def self.ruby def self.ruby
require "shellwords"
# Gem.ruby is quoted if it contains whitespace # Gem.ruby is quoted if it contains whitespace
cmd = Gem.ruby.shellsplit cmd = Shellwords.split(Gem.ruby)
# This load_path is only needed when running rubygems test without a proper installation. # This load_path is only needed when running rubygems test without a proper installation.
# Prepending it in a normal installation will cause problem with order of $LOAD_PATH. # Prepending it in a normal installation will cause problem with order of $LOAD_PATH.
@ -82,8 +82,7 @@ class Gem::Ext::Builder
p(command) p(command)
end end
results << "current directory: #{dir}" results << "current directory: #{dir}"
require "shellwords" results << Shellwords.join(command)
results << command.shelljoin
require "open3" require "open3"
# Set $SOURCE_DATE_EPOCH for the subprocess. # Set $SOURCE_DATE_EPOCH for the subprocess.

View File

@ -1,5 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
require_relative "../shellwords"
# This class is used by rubygems to build Rust extensions. It is a thin-wrapper # This class is used by rubygems to build Rust extensions. It is a thin-wrapper
# over the `cargo rustc` command which takes care of building Rust code in a way # over the `cargo rustc` command which takes care of building Rust code in a way
# that Ruby can use. # that Ruby can use.
@ -73,8 +75,6 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder
end end
def cargo_command(cargo_toml, dest_path, args = [], crate_name = nil) def cargo_command(cargo_toml, dest_path, args = [], crate_name = nil)
require "shellwords"
cmd = [] cmd = []
cmd += [cargo, "rustc"] cmd += [cargo, "rustc"]
cmd += ["--crate-type", "cdylib"] cmd += ["--crate-type", "cdylib"]

View File

@ -1,5 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
require_relative "../shellwords"
#-- #--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others. # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved. # All rights reserved.
@ -15,8 +17,7 @@ class Gem::Ext::RakeBuilder < Gem::Ext::Builder
rake = ENV["rake"] rake = ENV["rake"]
if rake if rake
require "shellwords" rake = Shellwords.split(rake)
rake = rake.shellsplit
else else
begin begin
rake = ruby << "-rrubygems" << Gem.bin_path("rake", "rake") rake = ruby << "-rrubygems" << Gem.bin_path("rake", "rake")

View File

@ -0,0 +1,3 @@
# frozen_string_literal: true
autoload :Shellwords, "shellwords"