summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
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')