File tree 1 file changed +15
-1
lines changed
1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 54
54
import math
55
55
import os
56
56
import re
57
+ import shlex
57
58
import shutil
58
59
import subprocess
59
60
import sys
@@ -893,8 +894,21 @@ def init_tmp_with_template():
893
894
894
895
init_tmp_with_template ()
895
896
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
+
896
910
while True :
897
- subprocess .run ([ editor , tmp_path ] )
911
+ subprocess .run (args )
898
912
899
913
failure = None
900
914
blurb = Blurbs ()
You can’t perform that action at this time.
0 commit comments