summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorTodd Leonhardt <tleonhardt@gmail.com>2017-06-28 17:10:10 -0400
committerTodd Leonhardt <tleonhardt@gmail.com>2017-06-28 17:10:10 -0400
commit38f509964141530a246effb87c0d3ed30e6918b1 (patch)
tree4f9b3d28bc7e304043eb5157928c1d9dc2f658e1 /cmd2.py
parent662b0857825b850982bf188fca60801f29f5d54f (diff)
downloadcmd2-git-38f509964141530a246effb87c0d3ed30e6918b1.tar.gz
Fixed crash in edit if called with no argument and empty history
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/cmd2.py b/cmd2.py
index 73ed064b..a55fb09e 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -1714,7 +1714,11 @@ Edited files are run on close if the ``autorun_on_edit`` settable parameter is T
filename = arg
buffer = ''
else:
- buffer = self.history[-1]
+ try:
+ buffer = self.history[-1]
+ except IndexError:
+ self.perror('edit must be called with argument if history is empty', traceback_war=False)
+ return
if buffer:
f = open(os.path.expanduser(filename), 'w')