From 3cc22374f9b66baa148b2ea30370b6822f925461 Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Fri, 24 Jan 2014 20:40:38 -0500 Subject: [PATCH 01/13] doubledash hygiene for external cmd: sudo, AND also includes doubledash hygiene for any child commands following each sudo --- lib/cask.rb | 4 ++-- lib/cask/system_command.rb | 2 +- test/cask/artifact/pkg_test.rb | 27 ++++++++++++++------------- test/cask/pkg_test.rb | 2 +- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/lib/cask.rb b/lib/cask.rb index 4a642ac8e6d7..a54357759759 100644 --- a/lib/cask.rb +++ b/lib/cask.rb @@ -51,8 +51,8 @@ def self.init system '/bin/mkdir', caskroom else # sudo in system is rude. - system '/usr/bin/sudo', '/bin/mkdir', '-p', caskroom - system '/usr/bin/sudo', '/usr/sbin/chown', '-R', "#{current_user}:staff", caskroom.parent + system '/usr/bin/sudo', '--', '/bin/mkdir', '-p', '--', caskroom + system '/usr/bin/sudo', '--', '/usr/sbin/chown', '-R', '--', "#{current_user}:staff", caskroom.parent end end appdir.mkpath unless appdir.exist? diff --git a/lib/cask/system_command.rb b/lib/cask/system_command.rb index 41a3709d7797..33292b52f732 100644 --- a/lib/cask/system_command.rb +++ b/lib/cask/system_command.rb @@ -27,7 +27,7 @@ def self.run!(command, options) def self._process_options(command, options) if options[:sudo] - command = "/usr/bin/sudo -E #{_quote(command)}" + command = "/usr/bin/sudo -E -- #{_quote(command)}" end if options[:args] command = "#{command} #{options[:args].map { |arg| _quote(arg) }.join(' ')}" diff --git a/test/cask/artifact/pkg_test.rb b/test/cask/artifact/pkg_test.rb index 2257abc5e028..c35c3049633b 100644 --- a/test/cask/artifact/pkg_test.rb +++ b/test/cask/artifact/pkg_test.rb @@ -12,7 +12,7 @@ it 'runs the system installer on the specified pkgs' do pkg = Cask::Artifact::Pkg.new(@cask, Cask::FakeSystemCommand) - expected_command = "/usr/bin/sudo -E '/usr/sbin/installer' '-pkg' '#{@cask.destination_path/'MyFancyPkg'/'Fancy.pkg'}' '-target' '/' 2>&1" + expected_command = "/usr/bin/sudo -E -- '/usr/sbin/installer' '-pkg' '#{@cask.destination_path/'MyFancyPkg'/'Fancy.pkg'}' '-target' '/' 2>&1" Cask::FakeSystemCommand.stubs_command(expected_command) shutup do @@ -27,10 +27,10 @@ it 'runs the specified uninstaller for the cask' do pkg = Cask::Artifact::Pkg.new(@cask, Cask::FakeSystemCommand) - Cask::FakeSystemCommand.stubs_command(%Q(/usr/bin/sudo -E '/usr/bin/osascript' '-e' 'tell application "System Events" to count processes whose bundle identifier is "my.fancy.package.app"' 2>&1), '1') - Cask::FakeSystemCommand.stubs_command(%Q(/usr/bin/sudo -E '/usr/bin/osascript' '-e' 'tell application id "my.fancy.package.app" to quit' 2>&1)) + Cask::FakeSystemCommand.stubs_command(%Q(/usr/bin/sudo -E -- '/usr/bin/osascript' '-e' 'tell application "System Events" to count processes whose bundle identifier is "my.fancy.package.app"' 2>&1), '1') + Cask::FakeSystemCommand.stubs_command(%Q(/usr/bin/sudo -E -- '/usr/bin/osascript' '-e' 'tell application id "my.fancy.package.app" to quit' 2>&1)) - expected_command = "/usr/bin/sudo -E '#{@cask.destination_path/'MyFancyPkg'/'FancyUninstaller.tool'}' '--please' 2>&1" + expected_command = "/usr/bin/sudo -E -- '#{@cask.destination_path/'MyFancyPkg'/'FancyUninstaller.tool'}' '--please' 2>&1" Cask::FakeSystemCommand.stubs_command(expected_command) shutup do @@ -82,12 +82,13 @@ PLIST ) + Cask::FakeSystemCommand.stubs_command( %Q(/bin/launchctl 'list' '-x' 'my.fancy.package.service' 2>&1), "launchctl list returned unknown response\n" ) Cask::FakeSystemCommand.stubs_command( - %Q(/usr/bin/sudo -E '/bin/launchctl' 'list' '-x' 'my.fancy.package.service' 2>&1), + %Q(/usr/bin/sudo -E -- '/bin/launchctl' 'list' '-x' 'my.fancy.package.service' 2>&1), <<-PLIST @@ -111,11 +112,11 @@ PLIST ) - Cask::FakeSystemCommand.expects_command(%Q(/usr/bin/sudo -E '/bin/launchctl' 'remove' 'my.fancy.package.service' 2>&1)) + Cask::FakeSystemCommand.expects_command(%Q(/usr/bin/sudo -E -- '/bin/launchctl' 'remove' '--' 'my.fancy.package.service' 2>&1)) - Cask::FakeSystemCommand.stubs_command(%Q(/usr/bin/sudo -E '/usr/sbin/kextstat' '-l' '-b' 'my.fancy.package.kernelextension' 2>&1), 'loaded') - Cask::FakeSystemCommand.expects_command(%Q(/usr/bin/sudo -E '/sbin/kextunload' '-b' 'my.fancy.package.kernelextension' 2>&1)) - Cask::FakeSystemCommand.stubs_command(%Q(/usr/bin/sudo -E '/usr/sbin/pkgutil' '--forget' 'my.fancy.package.main' 2>&1)) + Cask::FakeSystemCommand.stubs_command(%Q(/usr/bin/sudo -E -- '/usr/sbin/kextstat' '-l' '-b' 'my.fancy.package.kernelextension' 2>&1), 'loaded') + Cask::FakeSystemCommand.expects_command(%Q(/usr/bin/sudo -E -- '/sbin/kextunload' '-b' '--' 'my.fancy.package.kernelextension' 2>&1)) + Cask::FakeSystemCommand.stubs_command(%Q(/usr/bin/sudo -E -- '/usr/sbin/pkgutil' '--forget' 'my.fancy.package.main' 2>&1)) Cask::FakeSystemCommand.stubs_command( %Q(/usr/sbin/pkgutil '--only-files' '--files' 'my.fancy.package.agent' 2>&1), @@ -154,13 +155,13 @@ /tmp/fancy/bin /tmp/fancy/var ].each do |dir| - Cask::FakeSystemCommand.stubs_command(%Q(/usr/bin/sudo -E '/bin/chmod' '777' '#{dir}' 2>&1)) + Cask::FakeSystemCommand.stubs_command(%Q(/usr/bin/sudo -E -- '/bin/chmod' '--' '777' '#{dir}' 2>&1)) end - Cask::FakeSystemCommand.stubs_command(%Q(/usr/bin/sudo -E '/usr/sbin/pkgutil' '--forget' 'my.fancy.package.agent' 2>&1)) + Cask::FakeSystemCommand.stubs_command(%Q(/usr/bin/sudo -E -- '/usr/sbin/pkgutil' '--forget' 'my.fancy.package.agent' 2>&1)) - Cask::FakeSystemCommand.stubs_command(%Q(/usr/bin/sudo -E '/bin/rm' '-f' '/tmp/fancy/bin/fancy.exe' '/tmp/fancy/var/fancy.data' 2>&1)) - Cask::FakeSystemCommand.stubs_command(%Q(/usr/bin/sudo -E '/bin/rm' '-f' '/tmp/fancy/agent/fancy-agent.exe' '/tmp/fancy/agent/fancy-agent.pid' '/tmp/fancy/agent/fancy-agent.log' 2>&1)) + Cask::FakeSystemCommand.stubs_command(%Q(/usr/bin/sudo -E -- '/bin/rm' '-f' '--' '/tmp/fancy/bin/fancy.exe' '/tmp/fancy/var/fancy.data' 2>&1)) + Cask::FakeSystemCommand.stubs_command(%Q(/usr/bin/sudo -E -- '/bin/rm' '-f' '--' '/tmp/fancy/agent/fancy-agent.exe' '/tmp/fancy/agent/fancy-agent.pid' '/tmp/fancy/agent/fancy-agent.log' 2>&1)) # No assertions after call since all assertions are implicit from the interactions setup above. # TODO: verify rmdir commands (requires setting up actual file tree or faking out .exists? diff --git a/test/cask/pkg_test.rb b/test/cask/pkg_test.rb index 6c201f50b77d..c4acee830029 100644 --- a/test/cask/pkg_test.rb +++ b/test/cask/pkg_test.rb @@ -30,7 +30,7 @@ ) Cask::FakeSystemCommand.expects_command( - %q(/usr/bin/sudo -E '/usr/sbin/pkgutil' '--forget' 'my.fake.pkg' 2>&1) + %q(/usr/bin/sudo -E -- '/usr/sbin/pkgutil' '--forget' 'my.fake.pkg' 2>&1) ) pkg.uninstall From f4623843b71d39af187b9777c73da135d7611295 Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Fri, 24 Jan 2014 20:42:28 -0500 Subject: [PATCH 02/13] doubledash hygiene for external cmd: mv --- developer/bin/develop_brew_cask | 8 ++++---- developer/bin/production_brew_cask | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/developer/bin/develop_brew_cask b/developer/bin/develop_brew_cask index d7123abd61b2..c9e77c02abf3 100755 --- a/developer/bin/develop_brew_cask +++ b/developer/bin/develop_brew_cask @@ -64,13 +64,13 @@ not_inside_homebrew () { create_dev_links () { local tap_dir="$1" local git_root="$2" - /bin/mv rubylib production_rubylib - /bin/mv Casks production_Casks + /bin/mv -- rubylib production_rubylib + /bin/mv -- Casks production_Casks /bin/ln -s "$git_root/Casks" . /bin/ln -s "$git_root/lib" rubylib cd "$tap_dir" - /bin/mv lib production_lib - /bin/mv Casks production_Casks + /bin/mv -- lib production_lib + /bin/mv -- Casks production_Casks /bin/ln -s "$git_root/Casks" . /bin/ln -s "$git_root/lib" . printf "brew-cask is now in development mode\n" diff --git a/developer/bin/production_brew_cask b/developer/bin/production_brew_cask index e0c3fbebddb2..efff1c9fd0ee 100755 --- a/developer/bin/production_brew_cask +++ b/developer/bin/production_brew_cask @@ -64,12 +64,12 @@ not_inside_homebrew () { remove_dev_links () { local tap_dir="$1" /bin/rm rubylib Casks - /bin/mv production_rubylib rubylib - /bin/mv production_Casks Casks + /bin/mv -- production_rubylib rubylib + /bin/mv -- production_Casks Casks cd "$tap_dir" /bin/rm lib Casks - /bin/mv production_lib lib - /bin/mv production_Casks Casks + /bin/mv -- production_lib lib + /bin/mv -- production_Casks Casks printf "brew-cask is now in production mode\n" printf "It is safe to run 'brew update' if you are in production mode for all Caskroom repos.\n" } From b2de57cf0fb77552389e08af3d3b465b9451ad9a Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Fri, 24 Jan 2014 20:43:35 -0500 Subject: [PATCH 03/13] doubledash hygiene for external cmd: ln --- developer/bin/develop_brew_cask | 8 ++++---- lib/cask/artifact/hardlinked.rb | 2 +- lib/cask/artifact/symlinked.rb | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/developer/bin/develop_brew_cask b/developer/bin/develop_brew_cask index c9e77c02abf3..2faab778bc53 100755 --- a/developer/bin/develop_brew_cask +++ b/developer/bin/develop_brew_cask @@ -66,13 +66,13 @@ create_dev_links () { local git_root="$2" /bin/mv -- rubylib production_rubylib /bin/mv -- Casks production_Casks - /bin/ln -s "$git_root/Casks" . - /bin/ln -s "$git_root/lib" rubylib + /bin/ln -s -- "$git_root/Casks" . + /bin/ln -s -- "$git_root/lib" rubylib cd "$tap_dir" /bin/mv -- lib production_lib /bin/mv -- Casks production_Casks - /bin/ln -s "$git_root/Casks" . - /bin/ln -s "$git_root/lib" . + /bin/ln -s -- "$git_root/Casks" . + /bin/ln -s -- "$git_root/lib" . printf "brew-cask is now in development mode\n" printf "Note: it is not safe to run 'brew update' while in development mode\n" } diff --git a/lib/cask/artifact/hardlinked.rb b/lib/cask/artifact/hardlinked.rb index ed5cdaf10bb3..4daafcf50c29 100644 --- a/lib/cask/artifact/hardlinked.rb +++ b/lib/cask/artifact/hardlinked.rb @@ -9,6 +9,6 @@ def self.link_type_english_name end def create_filesystem_link(source, target) - @command.run!('/bin/ln', :args => ['-hf', source, target]) + @command.run!('/bin/ln', :args => ['-hf', '--', source, target]) end end diff --git a/lib/cask/artifact/symlinked.rb b/lib/cask/artifact/symlinked.rb index c5a60ec6705b..765f66a32226 100644 --- a/lib/cask/artifact/symlinked.rb +++ b/lib/cask/artifact/symlinked.rb @@ -8,7 +8,7 @@ def self.link_type_english_name end def create_filesystem_link(source, target) - @command.run!('/bin/ln', :args => ['-hfs', source, target]) + @command.run!('/bin/ln', :args => ['-hfs', '--', source, target]) end def link(artifact_relative_path) From 07889426b22aa909f9909474e50e052b716cddd7 Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Fri, 24 Jan 2014 20:44:17 -0500 Subject: [PATCH 04/13] doubledash hygiene for external cmd: ls --- developer/bin/develop_brew_cask | 2 +- developer/bin/production_brew_cask | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/developer/bin/develop_brew_cask b/developer/bin/develop_brew_cask index 2faab778bc53..8d98bf588f81 100755 --- a/developer/bin/develop_brew_cask +++ b/developer/bin/develop_brew_cask @@ -88,7 +88,7 @@ _develop_brew_cask () { local git_root="$(/bin/pwd)" local brew_prefix="$(brew --prefix)" local cellar_dir="$brew_prefix/Cellar/brew-cask" - local version_dir="$(/bin/ls "$cellar_dir/" | /usr/bin/sort | /usr/bin/tail -1)" + local version_dir="$(/bin/ls -- "$cellar_dir/" | /usr/bin/sort | /usr/bin/tail -1)" local tap_dir="$brew_prefix/$tap_subdir" # sanity check diff --git a/developer/bin/production_brew_cask b/developer/bin/production_brew_cask index efff1c9fd0ee..5fcdbec3e94d 100755 --- a/developer/bin/production_brew_cask +++ b/developer/bin/production_brew_cask @@ -85,7 +85,7 @@ _production_brew_cask () { local git_root="$(/bin/pwd)" local brew_prefix="$(brew --prefix)" local cellar_dir="$brew_prefix/Cellar/brew-cask" - local version_dir="$(/bin/ls "$cellar_dir/" | /usr/bin/sort | /usr/bin/tail -1)" + local version_dir="$(/bin/ls -- "$cellar_dir/" | /usr/bin/sort | /usr/bin/tail -1)" local tap_dir="$brew_prefix/$tap_subdir" # sanity check From e5a16f90e91120d5e90fd58581d6db720295b1d8 Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Wed, 29 Jan 2014 12:29:29 -0500 Subject: [PATCH 05/13] doubledash hygiene for external cmd: stat --- developer/bin/develop_brew_cask | 2 +- developer/bin/production_brew_cask | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/developer/bin/develop_brew_cask b/developer/bin/develop_brew_cask index 8d98bf588f81..cb046970b6ba 100755 --- a/developer/bin/develop_brew_cask +++ b/developer/bin/develop_brew_cask @@ -56,7 +56,7 @@ cd_to_version_dir () { not_inside_homebrew () { local tap_dir="$1" local git_root="$2" - if [[ "$(/usr/bin/stat -L -f '%i' "$tap_dir")" -eq "$(/usr/bin/stat -L -f '%i' "$git_root")" ]]; then + if [[ "$(/usr/bin/stat -L -f '%i' -- "$tap_dir")" -eq "$(/usr/bin/stat -L -f '%i' -- "$git_root")" ]]; then die "\nERROR: Run this script in your private repo, not inside Homebrew.\n" fi } diff --git a/developer/bin/production_brew_cask b/developer/bin/production_brew_cask index 5fcdbec3e94d..318f2803891f 100755 --- a/developer/bin/production_brew_cask +++ b/developer/bin/production_brew_cask @@ -56,7 +56,7 @@ cd_to_version_dir () { not_inside_homebrew () { local tap_dir="$1" local git_root="$2" - if [[ "$(/usr/bin/stat -L -f '%i' "$tap_dir")" -eq "$(/usr/bin/stat -L -f '%i' "$git_root")" ]]; then + if [[ "$(/usr/bin/stat -L -f '%i' -- "$tap_dir")" -eq "$(/usr/bin/stat -L -f '%i' -- "$git_root")" ]]; then die "\nERROR: Run this script in your private repo, not inside Homebrew.\n" fi } From a7f1bc6693d0f6172243f3b320fea982c75abc42 Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Fri, 24 Jan 2014 20:45:49 -0500 Subject: [PATCH 06/13] doubledash hygiene for external cmd: rm --- developer/bin/list_ids_in_pkg | 2 +- developer/bin/production_brew_cask | 4 ++-- lib/cask/artifact/pkg.rb | 2 +- lib/cask/pkg.rb | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/developer/bin/list_ids_in_pkg b/developer/bin/list_ids_in_pkg index a7a2fff68746..5da3a7fee77d 100755 --- a/developer/bin/list_ids_in_pkg +++ b/developer/bin/list_ids_in_pkg @@ -49,7 +49,7 @@ mark_up_sources () { _list_ids_in_pkg () { tmpdir=`/usr/bin/mktemp -d -t list_ids_in_pkg` - trap "/bin/rm -rf '$tmpdir'" EXIT + trap "/bin/rm -rf -- '$tmpdir'" EXIT /usr/sbin/pkgutil --expand "$1" "$tmpdir/unpack" diff --git a/developer/bin/production_brew_cask b/developer/bin/production_brew_cask index 318f2803891f..15fbb76bac9b 100755 --- a/developer/bin/production_brew_cask +++ b/developer/bin/production_brew_cask @@ -63,11 +63,11 @@ not_inside_homebrew () { remove_dev_links () { local tap_dir="$1" - /bin/rm rubylib Casks + /bin/rm -- rubylib Casks /bin/mv -- production_rubylib rubylib /bin/mv -- production_Casks Casks cd "$tap_dir" - /bin/rm lib Casks + /bin/rm -- lib Casks /bin/mv -- production_lib lib /bin/mv -- production_Casks Casks printf "brew-cask is now in production mode\n" diff --git a/lib/cask/artifact/pkg.rb b/lib/cask/artifact/pkg.rb index 447c4ab64988..44c5fb8a9994 100644 --- a/lib/cask/artifact/pkg.rb +++ b/lib/cask/artifact/pkg.rb @@ -118,7 +118,7 @@ def manually_uninstall(uninstall_options) if uninstall_options.key? :files uninstall_options[:files].each do |file| ohai "Removing file #{file}" - @command.run!('/bin/rm', :args => ['-rf', file], :sudo => true) + @command.run!('/bin/rm', :args => ['-rf', '--', file], :sudo => true) end end end diff --git a/lib/cask/pkg.rb b/lib/cask/pkg.rb index 9944e0559e3a..366b8e99604b 100644 --- a/lib/cask/pkg.rb +++ b/lib/cask/pkg.rb @@ -15,7 +15,7 @@ def initialize(package_id, command=Cask::SystemCommand) def uninstall odebug "Deleting pkg files" list('files').each_slice(500) do |file_slice| - @command.run('/bin/rm', :args => file_slice.unshift('-f'), :sudo => true) + @command.run('/bin/rm', :args => file_slice.unshift('-f', '--'), :sudo => true) end odebug "Deleting pkg directories" _deepest_path_first(list('dirs')).each do |dir| @@ -80,14 +80,14 @@ def _deepest_path_first(paths) def _clean_broken_symlinks(dir) dir.children.each do |child| if _broken_symlink?(child) - @command.run!('/bin/rm', :args => [child], :sudo => true) + @command.run!('/bin/rm', :args => ['--', child], :sudo => true) end end end def _clean_ds_store(dir) ds_store = dir.join('.DS_Store') - @command.run!('/bin/rm', :args => [ds_store], :sudo => true) if ds_store.exist? + @command.run!('/bin/rm', :args => ['--', ds_store], :sudo => true) if ds_store.exist? end def _broken_symlink?(path) From 6038fd221d419697dc8fc4a9c1229209c23ea728 Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Fri, 24 Jan 2014 20:46:37 -0500 Subject: [PATCH 07/13] doubledash hygiene for external cmd: ditto --- lib/cask/container/dmg.rb | 2 +- lib/cask/container/naked.rb | 2 +- lib/cask/container/tar.rb | 2 +- lib/cask/container/zip.rb | 2 +- test/cask/container/naked_test.rb | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/cask/container/dmg.rb b/lib/cask/container/dmg.rb index 5a5320aed87e..d1425173ff88 100644 --- a/lib/cask/container/dmg.rb +++ b/lib/cask/container/dmg.rb @@ -13,7 +13,7 @@ def extract mount! assert_mounts_found @mounts.each do |mount| - @command.run('/usr/bin/ditto', :args => [mount, @cask.destination_path]) + @command.run('/usr/bin/ditto', :args => ['--', mount, @cask.destination_path]) end ensure eject! diff --git a/lib/cask/container/naked.rb b/lib/cask/container/naked.rb index 242956e919bf..26c24f54fbab 100644 --- a/lib/cask/container/naked.rb +++ b/lib/cask/container/naked.rb @@ -8,7 +8,7 @@ def self.me?(criteria) end def extract - @command.run!('/usr/bin/ditto', :args => [@path, @cask.destination_path.join(target_file)]) + @command.run!('/usr/bin/ditto', :args => ['--', @path, @cask.destination_path.join(target_file)]) end def target_file diff --git a/lib/cask/container/tar.rb b/lib/cask/container/tar.rb index 251a6a86cc44..1f7682a4d98d 100644 --- a/lib/cask/container/tar.rb +++ b/lib/cask/container/tar.rb @@ -8,7 +8,7 @@ def self.me?(criteria) def extract Dir.mktmpdir do |staging_dir| @command.run!('/usr/bin/tar', :args => ['xf', @path, '-C', staging_dir]) - @command.run!('/usr/bin/ditto', :args => [staging_dir, @cask.destination_path]) + @command.run!('/usr/bin/ditto', :args => ['--', staging_dir, @cask.destination_path]) end end end diff --git a/lib/cask/container/zip.rb b/lib/cask/container/zip.rb index 725f6416f7af..260501415b06 100644 --- a/lib/cask/container/zip.rb +++ b/lib/cask/container/zip.rb @@ -8,7 +8,7 @@ def self.me?(criteria) def extract Dir.mktmpdir do |staging_dir| @command.run!('/usr/bin/unzip', :args => ['-qq', '-d', staging_dir, @path, '-x', '__MACOSX/*']) - @command.run!('/usr/bin/ditto', :args => [staging_dir, @cask.destination_path]) + @command.run!('/usr/bin/ditto', :args => ['--', staging_dir, @cask.destination_path]) end end end diff --git a/test/cask/container/naked_test.rb b/test/cask/container/naked_test.rb index b1e321daca86..11af3cf79016 100644 --- a/test/cask/container/naked_test.rb +++ b/test/cask/container/naked_test.rb @@ -11,7 +11,7 @@ cask = SpaceyCask.new path = '/tmp/downloads/kevin-spacey-1.2.pkg' expected_destination = cask.destination_path.join('kevin spacey.pkg') - expected_command = %Q(/usr/bin/ditto '#{path}' '#{expected_destination}' 2>&1) + expected_command = %Q(/usr/bin/ditto '--' '#{path}' '#{expected_destination}' 2>&1) Cask::FakeSystemCommand.stubs_command(expected_command) container = Cask::Container::Naked.new(cask, path, Cask::FakeSystemCommand) From 06395054d6d2d4719326f2bf3e940bd1fa49a98c Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Fri, 24 Jan 2014 20:47:05 -0500 Subject: [PATCH 08/13] doubledash hygiene for external cmd: open --- lib/cask/cli/home.rb | 4 ++-- test/cask/cli/home_test.rb | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/cask/cli/home.rb b/lib/cask/cli/home.rb index f7f710e5be0e..7e8a437a2f63 100644 --- a/lib/cask/cli/home.rb +++ b/lib/cask/cli/home.rb @@ -2,12 +2,12 @@ module Cask::CLI::Home def self.run(*cask_names) if cask_names.empty? odebug "Opening project homepage" - system "/usr/bin/open", 'http://caskroom.io/' + system "/usr/bin/open", '--', 'http://caskroom.io/' else cask_names.each do |cask_name| odebug "Opening homepage for Cask #{cask_name}" cask = Cask.load(cask_name) - system "/usr/bin/open", cask.homepage + system "/usr/bin/open", '--', cask.homepage end end end diff --git a/test/cask/cli/home_test.rb b/test/cask/cli/home_test.rb index 83c0f383a870..2b7eca49d3d3 100644 --- a/test/cask/cli/home_test.rb +++ b/test/cask/cli/home_test.rb @@ -26,22 +26,22 @@ module Cask::CLI::Home it 'opens the homepage for the specified cask' do Cask::CLI::Home.run('alfred') Cask::CLI::Home.system_commands.must_equal [ - ['/usr/bin/open', 'http://www.alfredapp.com/'] + ['/usr/bin/open', '--', 'http://www.alfredapp.com/'] ] end it 'works for multiple casks' do Cask::CLI::Home.run('alfred', 'adium') Cask::CLI::Home.system_commands.must_equal [ - ['/usr/bin/open', 'http://www.alfredapp.com/'], - ['/usr/bin/open', 'https://www.adium.im/'] + ['/usr/bin/open', '--', 'http://www.alfredapp.com/'], + ['/usr/bin/open', '--', 'https://www.adium.im/'] ] end it "opens the project page when no cask is specified" do Cask::CLI::Home.run Cask::CLI::Home.system_commands.must_equal [ - ['/usr/bin/open', 'http://caskroom.io/'], + ['/usr/bin/open', '--', 'http://caskroom.io/'], ] end end From d8a7e5aad9bfc0cd051f3ed1d0cf83690f18ae2d Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Fri, 24 Jan 2014 20:47:21 -0500 Subject: [PATCH 09/13] doubledash hygiene for external cmd: rmdir --- lib/cask/pkg.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cask/pkg.rb b/lib/cask/pkg.rb index 366b8e99604b..a5b605c2cbb2 100644 --- a/lib/cask/pkg.rb +++ b/lib/cask/pkg.rb @@ -54,7 +54,7 @@ def info def _rmdir(path) if path.children.empty? - @command.run!('/bin/rmdir', :args => [path], :sudo => true) + @command.run!('/bin/rmdir', :args => ['--', path], :sudo => true) end end From 0b1814979e8b03b83b7ba99dc5dde46027dde596 Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Fri, 24 Jan 2014 20:47:40 -0500 Subject: [PATCH 10/13] doubledash hygiene for external cmd: launchctl --- lib/cask/artifact/pkg.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cask/artifact/pkg.rb b/lib/cask/artifact/pkg.rb index 44c5fb8a9994..1352f0745199 100644 --- a/lib/cask/artifact/pkg.rb +++ b/lib/cask/artifact/pkg.rb @@ -74,7 +74,7 @@ def manually_uninstall(uninstall_options) [false, true].each do |with_sudo| xml_status = @command.run('/bin/launchctl', :args => ['list', '-x', service], :sudo => with_sudo) if %r{^<\?xml}.match(xml_status) - @command.run!('/bin/launchctl', :args => ['remove', service], :sudo => with_sudo) + @command.run!('/bin/launchctl', :args => ['remove', '--', service], :sudo => with_sudo) end end end From 4b87101f1fe4be42cff45a79300fb131433078cf Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Fri, 24 Jan 2014 20:47:55 -0500 Subject: [PATCH 11/13] doubledash hygiene for external cmd: chmod --- lib/cask/pkg.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cask/pkg.rb b/lib/cask/pkg.rb index a5b605c2cbb2..6425957c5c85 100644 --- a/lib/cask/pkg.rb +++ b/lib/cask/pkg.rb @@ -60,11 +60,11 @@ def _rmdir(path) def _with_full_permissions(path, &block) original_mode = (path.stat.mode % 01000).to_s(8) - @command.run!('/bin/chmod', :args => ['777', path], :sudo => true) + @command.run!('/bin/chmod', :args => ['--', '777', path], :sudo => true) block.call ensure if path.exist? # block may have removed dir - @command.run!('/bin/chmod', :args => [original_mode, path], :sudo => true) + @command.run!('/bin/chmod', :args => ['--', original_mode, path], :sudo => true) end end From 061483571cafcf511050e08710fa0c514fa8f516 Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Fri, 24 Jan 2014 20:48:07 -0500 Subject: [PATCH 12/13] doubledash hygiene for external cmd: kextunload --- lib/cask/artifact/pkg.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cask/artifact/pkg.rb b/lib/cask/artifact/pkg.rb index 1352f0745199..bbf02806f4cc 100644 --- a/lib/cask/artifact/pkg.rb +++ b/lib/cask/artifact/pkg.rb @@ -97,7 +97,7 @@ def manually_uninstall(uninstall_options) ohai "Unloading kernel extension #{kext}" is_loaded = @command.run!('/usr/sbin/kextstat', :args => ['-l', '-b', kext], :sudo => true) if is_loaded.length > 1 - @command.run!('/sbin/kextunload', :args => ['-b', kext], :sudo => true) + @command.run!('/sbin/kextunload', :args => ['-b', '--', kext], :sudo => true) end end end From 288805e6ea6c63d446b320bee84528649724c171 Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Fri, 24 Jan 2014 20:48:16 -0500 Subject: [PATCH 13/13] doubledash hygiene for external cmd: file --- lib/cask/container/criteria.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cask/container/criteria.rb b/lib/cask/container/criteria.rb index 701eac1a4e2d..213fcc169ad8 100644 --- a/lib/cask/container/criteria.rb +++ b/lib/cask/container/criteria.rb @@ -7,7 +7,7 @@ def initialize(path, command) end def file - @file ||= @command.run('/usr/bin/file', :args => ['-Izb', path]) + @file ||= @command.run('/usr/bin/file', :args => ['-Izb', '--', path]) end def imageinfo