Skip to content

Commit dae0f70

Browse files
Merge pull request #8644 from rubygems/deivid-rodriguez/remove-shellwords-autoload
Remove shellwords autoload (cherry picked from commit 5fce350)
1 parent 1770618 commit dae0f70

File tree

5 files changed

+19
-16
lines changed

5 files changed

+19
-16
lines changed

Manifest.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,6 @@ lib/rubygems/security/policy.rb
520520
lib/rubygems/security/signer.rb
521521
lib/rubygems/security/trust_dir.rb
522522
lib/rubygems/security_option.rb
523-
lib/rubygems/shellwords.rb
524523
lib/rubygems/source.rb
525524
lib/rubygems/source/git.rb
526525
lib/rubygems/source/installed.rb

lib/rubygems/ext/builder.rb

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#++
88

99
require_relative "../user_interaction"
10-
require_relative "../shellwords"
1110

1211
class Gem::Ext::Builder
1312
include Gem::UserInteraction
@@ -29,7 +28,7 @@ def self.make(dest_path, results, make_dir = Dir.pwd, sitedir = nil, targets = [
2928
target_rbconfig["configure_args"] =~ /with-make-prog\=(\w+)/
3029
make_program_name = ENV["MAKE"] || ENV["make"] || $1
3130
make_program_name ||= RUBY_PLATFORM.include?("mswin") ? "nmake" : "make"
32-
make_program = Shellwords.split(make_program_name)
31+
make_program = shellsplit(make_program_name)
3332

3433
# The installation of the bundled gems is failed when DESTDIR is empty in mswin platform.
3534
destdir = /\bnmake/i !~ make_program_name || ENV["DESTDIR"] && ENV["DESTDIR"] != "" ? format("DESTDIR=%s", ENV["DESTDIR"]) : ""
@@ -58,7 +57,7 @@ def self.make(dest_path, results, make_dir = Dir.pwd, sitedir = nil, targets = [
5857

5958
def self.ruby
6059
# Gem.ruby is quoted if it contains whitespace
61-
cmd = Shellwords.split(Gem.ruby)
60+
cmd = shellsplit(Gem.ruby)
6261

6362
# This load_path is only needed when running rubygems test without a proper installation.
6463
# Prepending it in a normal installation will cause problem with order of $LOAD_PATH.
@@ -83,7 +82,7 @@ def self.run(command, results, command_name = nil, dir = Dir.pwd, env = {})
8382
p(command)
8483
end
8584
results << "current directory: #{dir}"
86-
results << Shellwords.join(command)
85+
results << shelljoin(command)
8786

8887
require "open3"
8988
# Set $SOURCE_DATE_EPOCH for the subprocess.
@@ -127,6 +126,18 @@ def self.run(command, results, command_name = nil, dir = Dir.pwd, env = {})
127126
end
128127
end
129128

129+
def self.shellsplit(command)
130+
require "shellwords"
131+
132+
Shellwords.split(command)
133+
end
134+
135+
def self.shelljoin(command)
136+
require "shellwords"
137+
138+
Shellwords.join(command)
139+
end
140+
130141
##
131142
# Creates a new extension builder for +spec+. If the +spec+ does not yet
132143
# have build arguments, saved, set +build_args+ which is an ARGV-style

lib/rubygems/ext/cargo_builder.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require_relative "../shellwords"
4-
53
# This class is used by rubygems to build Rust extensions. It is a thin-wrapper
64
# over the `cargo rustc` command which takes care of building Rust code in a way
75
# that Ruby can use.
@@ -159,7 +157,7 @@ def platform_specific_rustc_args(dest_dir, flags = [])
159157
# We want to use the same linker that Ruby uses, so that the linker flags from
160158
# mkmf work properly.
161159
def linker_args
162-
cc_flag = Shellwords.split(makefile_config("CC"))
160+
cc_flag = self.class.shellsplit(makefile_config("CC"))
163161
linker = cc_flag.shift
164162
link_args = cc_flag.flat_map {|a| ["-C", "link-arg=#{a}"] }
165163

@@ -178,7 +176,7 @@ def mswin_link_args
178176

179177
def libruby_args(dest_dir)
180178
libs = makefile_config(ruby_static? ? "LIBRUBYARG_STATIC" : "LIBRUBYARG_SHARED")
181-
raw_libs = Shellwords.split(libs)
179+
raw_libs = self.class.shellsplit(libs)
182180
raw_libs.flat_map {|l| ldflag_to_link_modifier(l) }
183181
end
184182

@@ -261,7 +259,7 @@ def rustc_lib_flags(dest_dir)
261259
end
262260

263261
def split_flags(var)
264-
Shellwords.split(RbConfig::CONFIG.fetch(var, ""))
262+
self.class.shellsplit(RbConfig::CONFIG.fetch(var, ""))
265263
end
266264

267265
def ldflag_to_link_modifier(arg)

lib/rubygems/ext/rake_builder.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require_relative "../shellwords"
4-
53
#--
64
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
75
# All rights reserved.
@@ -22,7 +20,7 @@ def self.build(extension, dest_path, results, args=[], lib_dir=nil, extension_di
2220
rake = ENV["rake"]
2321

2422
if rake
25-
rake = Shellwords.split(rake)
23+
rake = shellsplit(rake)
2624
else
2725
begin
2826
rake = ruby << "-rrubygems" << Gem.bin_path("rake", "rake")

lib/rubygems/shellwords.rb

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)