summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2018-03-16 22:43:44 -0400
committerGitHub <noreply@github.com>2018-03-16 22:43:44 -0400
commit286ae5c958e0132ccc82f170aa08521bb6439f64 (patch)
treeb516a76aa6f89c3d93a83999c6952bee2cf89486 /cmd2.py
parentf0429e3f96a11572abcd07248730da8219b40c5c (diff)
parent24fdbbce8a7bb0df3b12fc91cb53a591777f9fb0 (diff)
downloadcmd2-git-286ae5c958e0132ccc82f170aa08521bb6439f64.tar.gz
Merge pull request #318 from python-cmd2/default_on_shell_unit_tests
Default on shell unit tests
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/cmd2.py b/cmd2.py
index 7ce6e5c0..d2f26166 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -1578,14 +1578,18 @@ class Cmd(cmd.Cmd):
break
i, n = 0, len(line)
- while i < n and line[i] in self.identchars:
- i += 1
- command, arg = line[:i], line[i:].strip()
- # Make sure there is a space between the command and args
- # This can occur when a character not in self.identchars bumps against the command (ex: help@)
- if len(command) > 0 and len(arg) > 0 and line[len(command)] != ' ':
- line = line.replace(command, command + ' ', 1)
+ # If we are allowing shell commands, then allow any character in the command
+ if self.default_to_shell:
+ while i < n and line[i] != ' ':
+ i += 1
+
+ # Otherwise only allow those in identchars
+ else:
+ while i < n and line[i] in self.identchars:
+ i += 1
+
+ command, arg = line[:i], line[i:].strip()
return command, arg, line