summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkmvanbrunt <kmvanbrunt@gmail.com>2018-04-06 12:31:42 -0400
committerGitHub <noreply@github.com>2018-04-06 12:31:42 -0400
commit8a0d3cfcfbac869e28827cc15fe59ed8ea42fa95 (patch)
treed0d2897d4fcc63b5a3613f3da42a7af8e99f2365
parent4c9e18ceec716d83b574353739cf4837002ca396 (diff)
parent80da52f80ff86f3a7d88715931658811ca61b07a (diff)
downloadcmd2-git-8a0d3cfcfbac869e28827cc15fe59ed8ea42fa95.tar.gz
Merge pull request #337 from python-cmd2/shell_expansion
No longer expanding env vars since the shell will do that
-rwxr-xr-xcmd2.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/cmd2.py b/cmd2.py
index ae37e943..b7015a2b 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -3072,11 +3072,13 @@ Usage: Usage: unalias [-a] name [name ...]
Usage: shell <command> [arguments]"""
try:
- tokens = shlex.split(command, posix=POSIX_SHLEX)
+ # Use non-POSIX parsing to keep the quotes around the tokens
+ tokens = shlex.split(command, posix=False)
except ValueError as err:
self.perror(err, traceback_war=False)
return
+ # Support expanding ~ in quoted paths
for index, _ in enumerate(tokens):
if len(tokens[index]) > 0:
# Check if the token is quoted. Since shlex.split() passed, there isn't
@@ -3085,7 +3087,6 @@ Usage: Usage: unalias [-a] name [name ...]
if first_char in QUOTES:
tokens[index] = strip_quotes(tokens[index])
- tokens[index] = os.path.expandvars(tokens[index])
tokens[index] = os.path.expanduser(tokens[index])
# Restore the quotes