File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 5454import math
5555import os
5656import re
57+ import shlex
5758import shutil
5859import subprocess
5960import sys
@@ -893,8 +894,21 @@ def init_tmp_with_template():
893894
894895 init_tmp_with_template ()
895896
897+ # We need to be clever about EDITOR.
898+ # On the one hand, it might be a legitimate path to an
899+ # executable containing spaces.
900+ # On the other hand, it might be a partial command-line
901+ # with options.
902+ if shutil .which (editor ):
903+ args = [editor ]
904+ else :
905+ args = list (shlex .split (editor ))
906+ if not shutil .which (args [0 ]):
907+ sys .exit ("Invalid GIT_EDITOR / EDITOR value: {}" .format (editor ))
908+ args .append (tmp_path )
909+
896910 while True :
897- subprocess .run ([ editor , tmp_path ] )
911+ subprocess .run (args )
898912
899913 failure = None
900914 blurb = Blurbs ()
You can’t perform that action at this time.
0 commit comments