don't crash when there the input is empty

This commit is contained in:
Romain Bignon 2012-07-23 17:25:07 +02:00
commit 538578c83f

View file

@ -328,6 +328,7 @@ class ReplApplication(Cmd, ConsoleApplication):
""" """
cmd, arg, ignored = Cmd.parseline(self, line) cmd, arg, ignored = Cmd.parseline(self, line)
if cmd is not None:
names = set(name for name in self.get_names() if name.startswith('do_')) names = set(name for name in self.get_names() if name.startswith('do_'))
if 'do_' + cmd not in names: if 'do_' + cmd not in names:
@ -378,9 +379,10 @@ class ReplApplication(Cmd, ConsoleApplication):
def default(self, line): def default(self, line):
print >>sys.stderr, 'Unknown command: "%s"' % line print >>sys.stderr, 'Unknown command: "%s"' % line
cmd, arg, ignore = Cmd.parseline(self, line) cmd, arg, ignore = Cmd.parseline(self, line)
if cmd is not None:
names = set(name[3:] for name in self.get_names() if name.startswith('do_' + cmd)) names = set(name[3:] for name in self.get_names() if name.startswith('do_' + cmd))
if len(names) > 0: if len(names) > 0:
print >>sys.stderr, 'Do you mean %s?' % ' '.join(names) print >>sys.stderr, 'Do you mean: %s?' % ', '.join(names)
return 2 return 2
def completenames(self, text, *ignored): def completenames(self, text, *ignored):