From c81804825c03e563ab748aae84c3f63458961208 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marc=20Cornell=C3=A0?= <hello@mcornella.com>
Date: Fri, 25 Feb 2022 14:06:19 +0100
Subject: [PATCH] fix(installer): fix removal of OMZ directory on failure

When the `git init` call fails, the directory is not created,
so the rm command fails with a not found error. This change
checks whether the directory exists before deleting it.
---
 tools/install.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/install.sh b/tools/install.sh
index 7953ad112..93608eb7c 100755
--- a/tools/install.sh
+++ b/tools/install.sh
@@ -283,7 +283,7 @@ setup_ohmyzsh() {
   && git remote add origin "$REMOTE" \
   && git fetch --depth=1 origin \
   && git checkout -b "$BRANCH" "origin/$BRANCH" || {
-    rm -rf "$ZSH"
+    [ ! -d "$ZSH" ] || rm -rf "$ZSH" 2>/dev/null
     fmt_error "git clone of oh-my-zsh repo failed"
     exit 1
   }