diff --git a/Library/Homebrew/cask/lib/hbc/system_command.rb b/Library/Homebrew/cask/lib/hbc/system_command.rb index ea440991f1..f64d85c075 100644 --- a/Library/Homebrew/cask/lib/hbc/system_command.rb +++ b/Library/Homebrew/cask/lib/hbc/system_command.rb @@ -1,5 +1,6 @@ require "open3" require "vendor/plist/plist" +require "shellwords" require "extend/io" @@ -49,11 +50,11 @@ module Hbc end def command - @command ||= [ - *sudo_prefix, - executable, - *args, - ].freeze + @command ||= if sudo? + [*sudo_prefix, executable, *args] + else + [Shellwords.shellescape(executable), *args] + end end private