diff options
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | cmd2/cmd2.py | 8 |
2 files changed, 7 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 3137ef07..6764f0ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ * Fixed bug where multiline commands were having leading and ending spaces stripped. This would mess up quoted strings that crossed multiple lines. * Fixed a bug when appending to the clipboard where contents were in reverse order - * Fixed issue where run_pyscript failed if the script's filename had a space + * Fixed issue where run_pyscript failed if the script's filename had 2 or more consecutive spaces * Enhancements * Greatly simplified using argparse-based tab completion. The new interface is a complete overhaul that breaks the previous way of specifying completion and choices functions. See header of [argparse_custom.py](https://github.com/python-cmd2/cmd2/blob/master/cmd2/argparse_custom.py) diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 63d3b958..79e7aad8 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -3248,8 +3248,8 @@ class Cmd(cmd.Cmd): # This is a hidden flag for telling do_py to run a pyscript. It is intended only to be used by run_pyscript # after it sets up sys.argv for the script being run. When this flag is present, it takes precedence over all - # other arguments. run_pyscript uses this method instead of "py run('file')" because file names with spaces cause - # issues with our parser, which isn't meant to parse Python statements. + # other arguments. run_pyscript uses this method instead of "py run('file')" because file names with + # 2 or more consecutive spaces cause issues with our parser, which isn't meant to parse Python statements. py_parser.add_argument('--pyscript', help=argparse.SUPPRESS) # Preserve quotes since we are passing these strings to Python @@ -3270,6 +3270,10 @@ class Cmd(cmd.Cmd): # Handle case where we were called by run_pyscript if args.pyscript: + args.pyscript = utils.strip_quotes(args.pyscript) + + # Run the script - use repr formatting to escape things which + # need to be escaped to prevent issues on Windows py_code_to_run = 'run({!r})'.format(args.pyscript) elif args.command: |