From 530cee44c37fa02c06b04b18349a89817df920f3 Mon Sep 17 00:00:00 2001 From: Markus Reiter <me@reitermark.us> Date: Wed, 21 Sep 2016 19:05:35 +0200 Subject: [PATCH] Use `sudo mv` to move Caskroom. --- Library/Homebrew/cask/lib/hbc/caskroom.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/cask/lib/hbc/caskroom.rb b/Library/Homebrew/cask/lib/hbc/caskroom.rb index b5443a8b7c..7dcb35d41b 100644 --- a/Library/Homebrew/cask/lib/hbc/caskroom.rb +++ b/Library/Homebrew/cask/lib/hbc/caskroom.rb @@ -6,12 +6,12 @@ module Hbc::Caskroom if !Hbc.caskroom.exist? && repo_caskroom.directory? ohai "Moving Caskroom from HOMEBREW_REPOSITORY to HOMEBREW_PREFIX" - unless Hbc.caskroom.parent.writable? - opoo "#{Hbc.caskroom.parent} is not writable, changing owner to current user." - system "/usr/bin/sudo", "--", "/usr/sbin/chown", "--", "#{Hbc::Utils.current_user}:staff", Hbc.caskroom.parent.to_s + if Hbc.caskroom.parent.writable? + FileUtils.mv repo_caskroom, Hbc.caskroom + else + opoo "#{Hbc.caskroom.parent} is not writable, sudo is needed to move the Caskroom." + system "/usr/bin/sudo", "--", "/bin/mv", "--", repo_caskroom.to_s, Hbc.caskroom.parent.to_s end - - FileUtils.mv repo_caskroom, Hbc.caskroom end end -- GitLab