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 1/3] 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 From d462f41c8cb4a3f6283acb61889b7de85ce9501c Mon Sep 17 00:00:00 2001 From: JEEVITHA KANNAN K S Date: Fri, 4 Oct 2024 16:36:06 +0530 Subject: [PATCH 2/3] Update core/tabs/system-setup/remove-snaps.sh Co-authored-by: Nyx <144965845+nnyyxxxx@users.noreply.github.com> --- core/tabs/system-setup/remove-snaps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/tabs/system-setup/remove-snaps.sh b/core/tabs/system-setup/remove-snaps.sh index 03913ba7..871679b5 100644 --- a/core/tabs/system-setup/remove-snaps.sh +++ b/core/tabs/system-setup/remove-snaps.sh @@ -24,7 +24,7 @@ removeSnaps() { esac printf "%b\n" "${GREEN}Successfully removed snaps...${RC}" else - printf "%b\n" "${GREEN}Snap is not installed...${RC}" + printf "%b\n" "${GREEN}Snapd is not installed...${RC}" fi } From 976d708c7f3fa15c23c7561d719913529ddd3e7a Mon Sep 17 00:00:00 2001 From: JEEVITHA KANNAN K S Date: Fri, 4 Oct 2024 22:59:28 +0530 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Adam Perkowski --- core/tabs/system-setup/remove-snaps.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/tabs/system-setup/remove-snaps.sh b/core/tabs/system-setup/remove-snaps.sh index 871679b5..a46ef323 100644 --- a/core/tabs/system-setup/remove-snaps.sh +++ b/core/tabs/system-setup/remove-snaps.sh @@ -22,9 +22,9 @@ removeSnaps() { exit 1 ;; esac - printf "%b\n" "${GREEN}Successfully removed snaps...${RC}" + printf "%b\n" "${GREEN}Successfully removed snaps.${RC}" else - printf "%b\n" "${GREEN}Snapd is not installed...${RC}" + printf "%b\n" "${GREEN}Snapd is not installed.${RC}" fi }