summaryrefslogtreecommitdiff
path: root/cmd2/cmd2.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2018-10-01 15:59:35 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2018-10-01 15:59:35 -0400
commitbc74542becb69980d8009af5272882530b92376c (patch)
tree16a5294564a6cf2d3da87bbca851d20af95bb3f0 /cmd2/cmd2.py
parentaae1c61bab32188be9c47c125604c81db120885f (diff)
downloadcmd2-git-bc74542becb69980d8009af5272882530b92376c.tar.gz
Preserving quotes for do_py input
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r--cmd2/cmd2.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index 79d3c80a..03c71a91 100644
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -2892,6 +2892,7 @@ class Cmd(cmd.Cmd):
help='arguments to pass to command'),
ACTION_ARG_CHOICES, ('path_complete',))
+ # Preserve quotes since we are passing these strings to the shell
@with_argparser(shell_parser, preserve_quotes=True)
def do_shell(self, args: argparse.Namespace) -> None:
"""Execute a command as if at the OS prompt"""
@@ -2947,7 +2948,8 @@ class Cmd(cmd.Cmd):
py_parser.add_argument('command', help="command to run", nargs='?')
py_parser.add_argument('remainder', help="remainder of command", nargs=argparse.REMAINDER)
- @with_argparser(py_parser)
+ # Preserve quotes since we are passing these strings to Python
+ @with_argparser(py_parser, preserve_quotes=True)
def do_py(self, args: argparse.Namespace) -> bool:
"""Invoke Python command or shell"""
from .pyscript_bridge import PyscriptBridge, CommandResult
@@ -2987,9 +2989,9 @@ class Cmd(cmd.Cmd):
interp.runcode('import sys, os;sys.path.insert(0, os.getcwd())')
if args.command:
- full_command = utils.quote_string_if_needed(args.command)
- for cur_token in args.remainder:
- full_command += ' ' + utils.quote_string_if_needed(cur_token)
+ full_command = args.command
+ if args.remainder:
+ full_command += ' ' + ' '.join(args.remainder)
interp.runcode(full_command)