From 7a22cda8ddc5dcd8304beab7767132bd4dcdafb9 Mon Sep 17 00:00:00 2001 From: Lucendio Date: Wed, 17 Mar 2021 00:35:08 +0100 Subject: [PATCH] Fix broken rmdir script Unfortunately, the removal shell script introduced in #10860 does not handle paths very well that dont exist, e.g. * `find` runs before its `-exec` test, thus throws `find: "${path}": No such file or directory` * it seem that `/bin/rmdir` is intended to break is certain cases, thus `-f` is not desired. so, if `${path}` does not exist, it'll still break, which is most likely not one of those cases. This change reintroduces a check for existence. This way, it is ensured that there is actually a directory to be removed when invoking the script. --- Library/Homebrew/cask/pkg.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Library/Homebrew/cask/pkg.rb b/Library/Homebrew/cask/pkg.rb index ca9cf34b75..ea7b0f3cb6 100644 --- a/Library/Homebrew/cask/pkg.rb +++ b/Library/Homebrew/cask/pkg.rb @@ -135,6 +135,8 @@ module Cask sig { params(path: T.any(Pathname, T::Array[Pathname])).void } def rmdir(path) + return unless path.exist? + @command.run!( "/usr/bin/xargs", args: ["-0", "--", "/bin/bash", "-c", RMDIR_SH, "--"],