From f05ef646973d787bd61d6fc2307307f8ed894592 Mon Sep 17 00:00:00 2001 From: KarimAziev Date: Fri, 3 May 2024 11:44:01 +0300 Subject: [PATCH] fix: add EMACS_DIRECTORY directory existence checks Add checks to ensure the EMACS_DIRECTORY exists --- build-emacs.sh | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/build-emacs.sh b/build-emacs.sh index 7866519..74383f4 100755 --- a/build-emacs.sh +++ b/build-emacs.sh @@ -203,15 +203,23 @@ pull_emacs() { } remove_emacs() { - cd "$EMACS_DIRECTORY" || exit 1 - echo "Uninstalling Emacs" - sudo make uninstall - echo "Cleaning Emacs" - sudo make extraclean + if [ -d "$EMACS_DIRECTORY" ]; then + cd "$EMACS_DIRECTORY" || exit 1 + echo "Uninstalling Emacs" + sudo make uninstall + echo "Cleaning Emacs" + sudo make extraclean + fi } build_emacs() { - cd "$EMACS_DIRECTORY" || exit 1 + if [ ! -d "$EMACS_DIRECTORY" ]; then + echo >&2 "build_emacs: Error - Directory '$EMACS_DIRECTORY' doesn't exist." + exit 1 + else + cd "$EMACS_DIRECTORY" + echo "Building Emacs" + fi ./autogen.sh ./configure \ @@ -237,7 +245,13 @@ build_emacs() { } install_emacs() { - cd "$EMACS_DIRECTORY" || exit 1 + if [ ! -d "$EMACS_DIRECTORY" ]; then + echo >&2 "install_emacs: Error - Directory '$EMACS_DIRECTORY' doesn't exist." + exit 1 + else + cd "$EMACS_DIRECTORY" + echo "Installing Emacs" + fi sudo make install }