Permalink
Browse files

Replace exit command set with regex.

  • Loading branch information...
takluyver committed Apr 12, 2011
1 parent 393fb5a commit 307de6c78a8514e232c24b9507d0fcdf8d3313ae
Showing with 5 additions and 6 deletions.
  1. +5 −6 IPython/core/history.py
View
@@ -88,11 +88,10 @@ def _dir_hist_default(self):
_ii = Unicode(u'')
_iii = Unicode(u'')
- # A set with all forms of the exit command, so that we don't store them in
- # the history (it's annoying to rewind the first entry and land on an exit
- # call).
- _exit_commands = Instance(set, args=(['Quit', 'quit', 'Exit', 'exit',
- '%Quit', '%quit', '%Exit', '%exit'],))
+ # A regex matching all forms of the exit command, so that we don't store
+ # them in the history (it's annoying to rewind the first entry and land on
+ # an exit call).
+ _exit_re = re.compile(r"(exit|quit)(\s*\(.*\))?$")
def __init__(self, shell, config=None, **traits):
"""Create a new history manager associated with a shell instance.
@@ -377,7 +376,7 @@ def store_inputs(self, line_num, source, source_raw=None):
source_raw = source_raw.rstrip('\n')
# do not store exit/quit commands
- if source_raw.strip() in self._exit_commands:
+ if self._exit_re.match(source_raw.strip()):
return
self.input_hist_parsed.append(source)

0 comments on commit 307de6c

Please sign in to comment.