Merge pull request #3514 from reitermarkus/system_command
Fix SystemCommand escaping … again.
This commit is contained in:
commit
c1b85a6f9d
@ -96,7 +96,7 @@ module Hbc
|
|||||||
if command.respond_to?(:run)
|
if command.respond_to?(:run)
|
||||||
# usual case: built-in command verb
|
# usual case: built-in command verb
|
||||||
command.run(*args)
|
command.run(*args)
|
||||||
elsif require?(which("brewcask-#{command}.rb"))
|
elsif require?(which("brewcask-#{command}.rb"), ENV["HOMEBREW_PATH"])
|
||||||
# external command as Ruby library on PATH, Homebrew-style
|
# external command as Ruby library on PATH, Homebrew-style
|
||||||
elsif command.to_s.include?("/") && require?(command.to_s)
|
elsif command.to_s.include?("/") && require?(command.to_s)
|
||||||
# external command as Ruby library with literal path, useful
|
# external command as Ruby library with literal path, useful
|
||||||
|
|||||||
@ -10,7 +10,7 @@ module Hbc
|
|||||||
end
|
end
|
||||||
|
|
||||||
def extract
|
def extract
|
||||||
if (cabextract = which("cabextract")).nil?
|
unless cabextract = which("cabextract", PATH.new(ENV["PATH"], HOMEBREW_PREFIX/"bin"))
|
||||||
raise CaskError, "Expected to find cabextract executable. Cask '#{@cask}' must add: depends_on formula: 'cabextract'"
|
raise CaskError, "Expected to find cabextract executable. Cask '#{@cask}' must add: depends_on formula: 'cabextract'"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -6,14 +6,14 @@ module Hbc
|
|||||||
class Container
|
class Container
|
||||||
class GenericUnar < Base
|
class GenericUnar < Base
|
||||||
def self.me?(criteria)
|
def self.me?(criteria)
|
||||||
!(lsar = which("lsar")).nil? &&
|
return false unless lsar = which("lsar", PATH.new(ENV["PATH"], HOMEBREW_PREFIX/"bin"))
|
||||||
criteria.command.run(lsar,
|
criteria.command.run(lsar,
|
||||||
args: ["-l", "-t", "--", criteria.path],
|
args: ["-l", "-t", "--", criteria.path],
|
||||||
print_stderr: false).stdout.chomp.end_with?("passed, 0 failed.")
|
print_stderr: false).stdout.chomp.end_with?("passed, 0 failed.")
|
||||||
end
|
end
|
||||||
|
|
||||||
def extract
|
def extract
|
||||||
if (unar = which("unar")).nil?
|
unless unar = which("unar", PATH.new(ENV["PATH"], HOMEBREW_PREFIX/"bin"))
|
||||||
raise CaskError, "Expected to find unar executable. Cask #{@cask} must add: depends_on formula: 'unar'"
|
raise CaskError, "Expected to find unar executable. Cask #{@cask} must add: depends_on formula: 'unar'"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -24,7 +24,7 @@ module Hbc
|
|||||||
end
|
end
|
||||||
|
|
||||||
def extract
|
def extract
|
||||||
if (gpg = which("gpg")).nil?
|
unless gpg = which("gpg", PATH.new(ENV["PATH"], HOMEBREW_PREFIX/"bin"))
|
||||||
raise CaskError, "Expected to find gpg executable. Cask '#{@cask}' must add: depends_on formula: 'gpg'"
|
raise CaskError, "Expected to find gpg executable. Cask '#{@cask}' must add: depends_on formula: 'gpg'"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@ module Hbc
|
|||||||
end
|
end
|
||||||
|
|
||||||
def extract
|
def extract
|
||||||
if (unlzma = which("unlzma")).nil?
|
unless unlzma = which("unlzma", PATH.new(ENV["PATH"], HOMEBREW_PREFIX/"bin"))
|
||||||
raise CaskError, "Expected to find unlzma executable. Cask '#{@cask}' must add: depends_on formula: 'lzma'"
|
raise CaskError, "Expected to find unlzma executable. Cask '#{@cask}' must add: depends_on formula: 'lzma'"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@ module Hbc
|
|||||||
end
|
end
|
||||||
|
|
||||||
def extract
|
def extract
|
||||||
if (unxz = which("unxz")).nil?
|
unless unxz = which("unxz", PATH.new(ENV["PATH"], HOMEBREW_PREFIX/"bin"))
|
||||||
raise CaskError, "Expected to find unxz executable. Cask '#{@cask}' must add: depends_on formula: 'xz'"
|
raise CaskError, "Expected to find unxz executable. Cask '#{@cask}' must add: depends_on formula: 'xz'"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -50,11 +50,7 @@ module Hbc
|
|||||||
end
|
end
|
||||||
|
|
||||||
def command
|
def command
|
||||||
@command ||= if sudo?
|
|
||||||
[*sudo_prefix, executable, *args]
|
[*sudo_prefix, executable, *args]
|
||||||
else
|
|
||||||
[Shellwords.shellescape(executable), *args]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@ -85,8 +81,14 @@ module Hbc
|
|||||||
end
|
end
|
||||||
|
|
||||||
def each_output_line(&b)
|
def each_output_line(&b)
|
||||||
|
executable, *args = expanded_command
|
||||||
|
|
||||||
|
unless File.exist?(executable)
|
||||||
|
executable = which(executable, PATH.new(ENV["PATH"], HOMEBREW_PREFIX/"bin"))
|
||||||
|
end
|
||||||
|
|
||||||
raw_stdin, raw_stdout, raw_stderr, raw_wait_thr =
|
raw_stdin, raw_stdout, raw_stderr, raw_wait_thr =
|
||||||
Open3.popen3(*expanded_command, **options)
|
Open3.popen3([executable, executable], *args, **options)
|
||||||
|
|
||||||
write_input_to(raw_stdin)
|
write_input_to(raw_stdin)
|
||||||
raw_stdin.close_write
|
raw_stdin.close_write
|
||||||
|
|||||||
@ -4,7 +4,6 @@ require "compat/hbc/cache"
|
|||||||
require "compat/hbc/caskroom"
|
require "compat/hbc/caskroom"
|
||||||
require "compat/hbc/cli"
|
require "compat/hbc/cli"
|
||||||
require "compat/hbc/dsl"
|
require "compat/hbc/dsl"
|
||||||
require "compat/hbc/system_command"
|
|
||||||
|
|
||||||
module Hbc
|
module Hbc
|
||||||
class << self
|
class << self
|
||||||
|
|||||||
@ -1,18 +0,0 @@
|
|||||||
require "shellwords"
|
|
||||||
|
|
||||||
module SystemCommandCompatibilityLayer
|
|
||||||
def initialize(executable, args: [], **options)
|
|
||||||
if args.empty? && !File.exist?(executable)
|
|
||||||
odeprecated "`system_command` with a shell string", "`system_command` with the `args` parameter"
|
|
||||||
executable, *args = Shellwords.shellsplit(executable)
|
|
||||||
end
|
|
||||||
|
|
||||||
super(executable, args: args, **options)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
module Hbc
|
|
||||||
class SystemCommand
|
|
||||||
prepend SystemCommandCompatibilityLayer
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@ -1622,7 +1622,7 @@ class Formula
|
|||||||
TEMP: HOMEBREW_TEMP,
|
TEMP: HOMEBREW_TEMP,
|
||||||
TMP: HOMEBREW_TEMP,
|
TMP: HOMEBREW_TEMP,
|
||||||
TERM: "dumb",
|
TERM: "dumb",
|
||||||
PATH: PATH.new(ENV["PATH"]).append(HOMEBREW_PREFIX/"bin"),
|
PATH: PATH.new(ENV["PATH"], HOMEBREW_PREFIX/"bin"),
|
||||||
HOMEBREW_PATH: nil,
|
HOMEBREW_PATH: nil,
|
||||||
_JAVA_OPTIONS: "#{ENV["_JAVA_OPTIONS"]} -Duser.home=#{HOMEBREW_CACHE}/java_cache",
|
_JAVA_OPTIONS: "#{ENV["_JAVA_OPTIONS"]} -Duser.home=#{HOMEBREW_CACHE}/java_cache",
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user