From fcd88b71f5eb0d9915264473dd0c155003563f89 Mon Sep 17 00:00:00 2001
From: Markus Reiter <me@reitermark.us>
Date: Thu, 16 Feb 2017 21:53:22 +0100
Subject: [PATCH] Allow skipping `uninstall script:` when `--force` is passed.

---
 .../Homebrew/cask/lib/hbc/artifact/uninstall_base.rb   | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb b/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb
index ce2b1f51a1..cc47e05ad3 100644
--- a/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb
+++ b/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb
@@ -201,7 +201,15 @@ module Hbc
         ohai "Running uninstall script #{executable}"
         raise CaskInvalidError.new(@cask, "#{stanza} :#{directive_name} without :executable.") if executable.nil?
         executable_path = @cask.staged_path.join(executable)
-        @command.run("/bin/chmod", args: ["--", "+x", executable_path]) if File.exist?(executable_path)
+
+        unless executable_path.exist?
+          message = "uninstall script #{executable} does not exist"
+          raise CaskError, "#{message}." unless force
+          opoo "#{message}, skipping."
+          return
+        end
+
+        @command.run("/bin/chmod", args: ["--", "+x", executable_path])
         @command.run(executable_path, script_arguments)
         sleep 1
       end
-- 
GitLab