From 2eb366ff386674bcd2eec760fdaef25dff665063 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 24 Oct 2017 18:28:21 +0200 Subject: [PATCH] Fix `SystemCommand` without arguments. --- .../Homebrew/cask/lib/hbc/system_command.rb | 3 --- Library/Homebrew/compat/hbc.rb | 1 + Library/Homebrew/compat/hbc/system_command.rb | 18 ++++++++++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 Library/Homebrew/compat/hbc/system_command.rb diff --git a/Library/Homebrew/cask/lib/hbc/system_command.rb b/Library/Homebrew/cask/lib/hbc/system_command.rb index 3c8311a3b3..ea440991f1 100644 --- a/Library/Homebrew/cask/lib/hbc/system_command.rb +++ b/Library/Homebrew/cask/lib/hbc/system_command.rb @@ -1,5 +1,4 @@ require "open3" -require "shellwords" require "vendor/plist/plist" require "extend/io" @@ -38,8 +37,6 @@ module Hbc end def initialize(executable, args: [], sudo: false, input: [], print_stdout: false, print_stderr: true, must_succeed: false, **options) - executable, *args = Shellwords.shellescape(executable) if args.empty? - @executable = executable @args = args @sudo = sudo diff --git a/Library/Homebrew/compat/hbc.rb b/Library/Homebrew/compat/hbc.rb index 608d46e376..ebf8a9874f 100644 --- a/Library/Homebrew/compat/hbc.rb +++ b/Library/Homebrew/compat/hbc.rb @@ -4,6 +4,7 @@ require "compat/hbc/cache" require "compat/hbc/caskroom" require "compat/hbc/cli" require "compat/hbc/dsl" +require "compat/hbc/system_command" module Hbc class << self diff --git a/Library/Homebrew/compat/hbc/system_command.rb b/Library/Homebrew/compat/hbc/system_command.rb new file mode 100644 index 0000000000..bb9187db37 --- /dev/null +++ b/Library/Homebrew/compat/hbc/system_command.rb @@ -0,0 +1,18 @@ +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