Skip to content

Commit 007e777

Browse files
committed
Fix a bug in history command
This is a bug that was introduced recently when the functionality of the list command was merged with the history command. This prevents an unhandled exception crash under certain unlikely but possible circumstances.
1 parent ccef0b4 commit 007e777

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

cmd2.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,8 +1610,11 @@ def do_history(self, arg, opts):
16101610
if arg:
16111611
# If a character indicating a slice is present, retrieve a slice of the history
16121612
if '..' in arg or ':' in arg:
1613-
# Get a slice of history
1614-
history = self.history.span(arg)
1613+
try:
1614+
# Get a slice of history
1615+
history = self.history.span(arg)
1616+
except IndexError:
1617+
history = self.history.get(arg)
16151618
else:
16161619
# Get item(s) from history by index or string search
16171620
history = self.history.get(arg)

0 commit comments

Comments
 (0)