Only use sudo if it is actually needed.
				
					
				
			This commit is contained in:
		
							parent
							
								
									29fd1d05dd
								
							
						
					
					
						commit
						e09eaf5b31
					
				@ -40,13 +40,13 @@ module Cask
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        ohai "Moving #{self.class.english_name} '#{source.basename}' to '#{target}'."
 | 
			
		||||
        if target.dirname.parent.writable?
 | 
			
		||||
        if target.dirname.ascend.find(&:directory?).writable?
 | 
			
		||||
          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)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user