summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2017-07-01 20:02:17 -0400
committerTodd Leonhardt <todd.leonhardt@gmail.com>2017-07-01 20:02:17 -0400
commit41d4aa2e7d9957dd13786e93a1af42949c82fa25 (patch)
tree8cc200383d5f4633511e608f1ea8232e7441f750 /cmd2.py
parenta949834c4c55b4fdbec32cba09e5fe5f5bdc15fa (diff)
downloadcmd2-git-41d4aa2e7d9957dd13786e93a1af42949c82fa25.tar.gz
Fixed unicode bug on Windows in pyscript command
Without using the repr representation of the path, "C:\Users" treats \U as a Unicode Escape. To fix this, pyscript passes the repr representation of the path to do_py.
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/cmd2.py b/cmd2.py
index 89ed1b7c..0177a18d 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -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