diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2019-07-20 17:12:16 -0400 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2019-07-20 17:12:16 -0400 |
commit | 01a6f9b4f4daa20ed0216a49147ec005349c77e1 (patch) | |
tree | 27e857070acb696c943ef6935f670b18f6221301 /cmd2/cmd2.py | |
parent | 5f87e874563e0cb7e46d01d45e2d0a66cf8a09e2 (diff) | |
download | cmd2-git-01a6f9b4f4daa20ed0216a49147ec005349c77e1.tar.gz |
Fixed unit tests
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r-- | cmd2/cmd2.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 5aeb4fdf..72784d4c 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -2109,10 +2109,13 @@ class Cmd(cmd.Cmd): :param saved_state: contains information needed to restore state data """ if saved_state.redirecting: + delete_name = None # If we redirected output to the clipboard if statement.output and not statement.output_to: self.stdout.seek(0) write_to_paste_buffer(self.stdout.read()) + if statement.output == constants.REDIRECTION_APPEND: + delete_name = self.stdout.name try: # Close the file or pipe that stdout was redirected to @@ -2120,6 +2123,10 @@ class Cmd(cmd.Cmd): except BrokenPipeError: pass + # If we appended to the clipboard, make sure to delete the tempfile + if delete_name is not None: + os.unlink(delete_name) + # Restore the stdout values self.stdout = saved_state.saved_self_stdout sys.stdout = saved_state.saved_sys_stdout |