Merge pull request #3362 from reitermarkus/system-command

Fix `SystemCommand` without arguments.
This commit is contained in:
Markus Reiter 2017-10-31 04:58:38 +01:00 committed by GitHub
commit 302bc8be22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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