From 188f251fa339eda74a97a790ac33b02a18363462 Mon Sep 17 00:00:00 2001 From: Kevin Van Brunt Date: Thu, 28 Jan 2021 16:49:19 -0500 Subject: Fixed FileNotFoundError which occurred when running 'history --clear' and no history file existed. --- cmd2/cmd2.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'cmd2/cmd2.py') diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 8ad3f7ba..ab72f1a6 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -3989,7 +3989,10 @@ class Cmd(cmd.Cmd): self.history.clear() if self.persistent_history_file: - os.remove(self.persistent_history_file) + try: + os.remove(self.persistent_history_file) + except FileNotFoundError: + pass if rl_type != RlType.NONE: readline.clear_history() -- cgit v1.2.1