summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2017-05-20 00:06:22 -0700
committerTodd Leonhardt <todd.leonhardt@gmail.com>2017-05-20 00:06:22 -0700
commit64b3a88f2376820ae0af2efeace6d63115fb4891 (patch)
tree27e797174b53931d102f9f52bc1714e3739c6c6f /cmd2.py
parent8297145a74ee4d239cfb7d68a47f59342fd831fe (diff)
downloadcmd2-git-64b3a88f2376820ae0af2efeace6d63115fb4891.tar.gz
Abbreviations are no longer accepted for multiline commands
Due to the way the parsing logic works for multiline commands, abbreviations didn't function properly with mutliline commands. So to avoid confusion, this commit deals with this issue by simply disallowing abbreviations for multiline commands altogether. A warning has been added to the section on abbreviations in the documentation to hopefully make this clear for users.
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/cmd2.py b/cmd2.py
index 1de93ec2..14203367 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -600,7 +600,7 @@ class Cmd(cmd.Cmd):
excludeFromHistory = '''run r list l history hi ed edit li eof'''.split()
# make sure your terminators are not in legalChars!
legalChars = u'!#$%.:?@_-' + pyparsing.alphanums + pyparsing.alphas8bit
- multilineCommands = []
+ multilineCommands = [] # NOTE: Multiline commands can never be abbreviated, even if abbrev is True
noSpecialParse = 'set ed edit exit'.split()
prefixParser = pyparsing.Empty()
redirector = '>' # for sending output to file
@@ -1089,7 +1089,7 @@ class Cmd(cmd.Cmd):
result = target
else:
if self.abbrev: # accept shortened versions of commands
- funcs = [fname for fname in self.keywords if fname.startswith(arg)]
+ funcs = [func for func in self.keywords if func.startswith(arg) and func not in self.multilineCommands]
if len(funcs) == 1:
result = 'do_' + funcs[0]
return result