From 13abdf3357ae60ffa29890ad2465c794ec363a48 Mon Sep 17 00:00:00 2001 From: deadc0de6 Date: Fri, 20 Jul 2018 23:44:49 +0200 Subject: [PATCH] require confirmation for rm -r --- dotdrop/updater.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dotdrop/updater.py b/dotdrop/updater.py index 0880ff1..98fd3b8 100644 --- a/dotdrop/updater.py +++ b/dotdrop/updater.py @@ -137,6 +137,8 @@ class Updater: continue if self.debug: self.log.dbg('rm -r {}'.format(new)) + if not self._confirm_rm_r(new): + continue utils.remove(new) # handle files diff @@ -208,3 +210,10 @@ class Updater: if self.safe and not self.log.ask(msg): return False return True + + def _confirm_rm_r(self, directory): + """ask for rm -r directory""" + msg = 'Recursively remove \"{}\"?'.format(directory) + if self.safe and not self.log.ask(msg): + return False + return True