summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkotfu <kotfu@kotfu.net>2018-05-06 10:20:34 -0600
committerkotfu <kotfu@kotfu.net>2018-05-06 10:20:34 -0600
commit339094832f9160e1961f4f95c4dc684413ab84c5 (patch)
tree8a205d3f4b851c300d9a82eff8136a24ce64a005
parent3343aad02757739fd7ddb91b095db277a59574d9 (diff)
downloadcmd2-git-339094832f9160e1961f4f95c4dc684413ab84c5.tar.gz
Clarify comments for self.invalid_alias_pattern
-rwxr-xr-xcmd2/cmd2.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index 5c82e953..764f3ce7 100755
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -731,6 +731,8 @@ class Cmd(cmd.Cmd):
self.broken_pipe_warning = ''
# regular expression to test for invalid characters in aliases
+ # we will construct it dynamically, because some of the components
+ # like terminator characters, can change
invalid_items = []
invalid_items.extend(constants.REDIRECTION_CHARS)
invalid_items.extend(self.terminators)
@@ -738,7 +740,8 @@ class Cmd(cmd.Cmd):
invalid_items = [re.escape(x) for x in invalid_items]
# don't allow whitespace
invalid_items.append(r'\s')
- # join them up with a pipe
+ # join them up with a pipe to form a regular expression
+ # that looks something like r';|>|\||\s'
expr = '|'.join(invalid_items)
# and compile it into a pattern
self.invalid_alias_pattern = re.compile(expr)