Skip to content

Commit

Permalink
Only use sudo if it is actually needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
reitermarkus committed Feb 7, 2019
1 parent 29fd1d0 commit e09eaf5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Library/Homebrew/cask/artifact/moved.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ def move(force: false, command: nil, **options)
end

ohai "Moving #{self.class.english_name} '#{source.basename}' to '#{target}'."
if target.dirname.parent.writable?
if target.dirname.ascend.find(&:directory?).writable?

This comment has been minimized.

Copy link
@doits

doits Feb 8, 2019

@reitermarkus it tries to do a /usr/bin/sudo -E -- /bin/mkdir -p /Applications for me even though I can write there (e.g. touch /Applications/bla creates bla without the need of sudo). Maybe the check is still not complete 100 %?

target.dirname.mkpath
else
command.run!("/bin/mkdir", args: ["-p", target.dirname], sudo: true)
end

if target.parent.writable?
if target.dirname.writable?
FileUtils.move(source, target)
else
command.run!("/bin/mv", args: [source, target], sudo: true)
Expand Down

0 comments on commit e09eaf5

Please sign in to comment.