From cd892a38a61e2cb5975189a8f6e61fe1cd72d2c1 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Thu, 3 Nov 2016 15:59:05 -0700 Subject: [PATCH] Allow quotes in editor command on Windows This change allows setting the EDITOR env. variable to point to a program location that contains quotes and spaces. For example: > set EDITOR="C:\Program Files (x86)\Notepad++\notepad++.exe" -multiInst -nosession > repo upload Change-Id: Ic95b00f7443982b1956a2992d0220e50b1cf6bbb --- editor.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/editor.py b/editor.py index 96d7ce4c..7980f2b4 100644 --- a/editor.py +++ b/editor.py @@ -83,7 +83,12 @@ least one of these before using this command.""", file=sys.stderr) os.close(fd) fd = None - if re.compile("^.*[$ \t'].*$").match(editor): + if platform_utils.isWindows(): + # Split on spaces, respecting quoted strings + import shlex + args = shlex.split(editor) + shell = False + elif re.compile("^.*[$ \t'].*$").match(editor): args = [editor + ' "$@"', 'sh'] shell = True else: