diff options
-rwxr-xr-x | cmd2.py | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -1421,7 +1421,7 @@ Paths or arguments that contain spaces must be enclosed in quotes arg = shlex.split(arg, posix=POSIX_SHLEX) # Get the absolute path of the script - script_path = os.path.abspath(os.path.expanduser(arg[0])) + script_path = os.path.expanduser(arg[0]) # Save current command line arguments orig_args = sys.argv @@ -1430,8 +1430,9 @@ Paths or arguments that contain spaces must be enclosed in quotes sys.argv = [script_path] sys.argv.extend(arg[1:]) - # Run the script - self.do_py("run('{}')".format(script_path)) + # Run the script - use repr formatting to escape things which need to be escaped to prevent issues on Windows + py_cmd = "run({!r})".format(script_path) + self.do_py(py_cmd) # Restore command line arguments to original state sys.argv = orig_args |