From 0e14d3a9dbbbf1291c0ef9956ffb7bd81fe7a7c2 Mon Sep 17 00:00:00 2001 From: JEEVITHA KANNAN K S Date: Fri, 4 Oct 2024 16:09:41 +0530 Subject: [PATCH] Add command_exists for snap --- core/tabs/system-setup/remove-snaps.sh | 44 ++++++++++++++------------ 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/core/tabs/system-setup/remove-snaps.sh b/core/tabs/system-setup/remove-snaps.sh index 6ea82934..03913ba7 100644 --- a/core/tabs/system-setup/remove-snaps.sh +++ b/core/tabs/system-setup/remove-snaps.sh @@ -3,27 +3,29 @@ . ../common-script.sh removeSnaps() { - case "$PACKAGER" in - pacman) - "$ESCALATION_TOOL" "$PACKAGER" -Rns snapd - ;; - apt-get|nala) - "$ESCALATION_TOOL" "$PACKAGER" autoremove --purge snapd - if [ "$ID" = ubuntu ]; then - "$ESCALATION_TOOL" apt-mark hold snapd - fi - ;; - dnf) - "$ESCALATION_TOOL" "$PACKAGER" remove snapd - ;; - zypper) - "$ESCALATION_TOOL" "$PACKAGER" remove snapd - ;; - *) - printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" - exit 1 - ;; - esac + if command_exists snap; then + case "$PACKAGER" in + pacman) + "$ESCALATION_TOOL" "$PACKAGER" -Rns snapd + ;; + apt-get|nala) + "$ESCALATION_TOOL" "$PACKAGER" autoremove --purge snapd + if [ "$ID" = ubuntu ]; then + "$ESCALATION_TOOL" apt-mark hold snapd + fi + ;; + dnf|zypper) + "$ESCALATION_TOOL" "$PACKAGER" remove snapd + ;; + *) + printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" + exit 1 + ;; + esac + printf "%b\n" "${GREEN}Successfully removed snaps...${RC}" + else + printf "%b\n" "${GREEN}Snap is not installed...${RC}" + fi } checkEnv