diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-10-01 17:01:12 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-01 17:01:12 -0400 |
commit | 9ca3476df3857cd5c89a5179e0e2578f95cb4425 (patch) | |
tree | 16a5294564a6cf2d3da87bbca851d20af95bb3f0 /cmd2/cmd2.py | |
parent | aae1c61bab32188be9c47c125604c81db120885f (diff) | |
parent | bc74542becb69980d8009af5272882530b92376c (diff) | |
download | cmd2-git-9ca3476df3857cd5c89a5179e0e2578f95cb4425.tar.gz |
Merge pull request #556 from python-cmd2/preserve_quotes
Preserving quotes for do_py input
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r-- | cmd2/cmd2.py | 10 |
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) |