From fcc401f6c632acfd0ed8587fd3540f65ba4b683c Mon Sep 17 00:00:00 2001
From: Giovanni Bussi <giovanni.bussi@gmail.com>
Date: Mon, 3 Aug 2015 13:22:56 +0200
Subject: [PATCH] safer uninstall

ask for confirm before deleting files
---
 src/lib/Makefile                | 11 +++++++++++
 src/maketools/confirm_uninstall | 18 ++++++++++++++++++
 2 files changed, 29 insertions(+)
 create mode 100755 src/maketools/confirm_uninstall

diff --git a/src/lib/Makefile b/src/lib/Makefile
index 5a6c8635f..07540fd65 100644
--- a/src/lib/Makefile
+++ b/src/lib/Makefile
@@ -216,6 +216,17 @@ endif
 
 
 uninstall:
+	@echo WARNING
+	@echo I will remove the following files now
+	@echo "$(DESTDIR)$(libdir)/$(program_name)"
+	@echo "$(DESTDIR)$(htmldir)"
+	@echo "$(DESTDIR)$(includedir)/$(program_name)"
+	@echo "$(DESTDIR)$(bindir)/$(program_name)"
+	@echo "$(DESTDIR)$(bindir)/$(program_name)-patch"
+	@echo "$(DESTDIR)$(libdir)/lib$(program_name).$(SOEXT)"
+	@echo "$(DESTDIR)$(libdir)/lib$(program_name)Kernel.$(SOEXT)"
+	../maketools/confirm_uninstall
+	@echo Removing previously installed files
 	rm -fr "$(DESTDIR)$(libdir)/$(program_name)"
 	rm -fr "$(DESTDIR)$(htmldir)"
 	rm -fr "$(DESTDIR)$(includedir)/$(program_name)"
diff --git a/src/maketools/confirm_uninstall b/src/maketools/confirm_uninstall
new file mode 100755
index 000000000..385febd27
--- /dev/null
+++ b/src/maketools/confirm_uninstall
@@ -0,0 +1,18 @@
+#! /bin/bash
+
+confirm () {
+    # call with a prompt string or use a default
+    read -r -p "${1:-Are you sure? [y/N]} " response
+    case $response in
+        [yY][eE][sS]|[yY])
+            true
+            ;;
+        *)
+            false
+            ;;
+    esac
+}
+
+confirm "Are you shure that you want to Uninstall? This might lead to data loss! [y/N]" || exit 1
+
+
-- 
GitLab