Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 15a4cd5

Browse filesBrowse files
Issue #162: make blurb sophisticated about EDITOR. (#206)
EDITOR might contain spaces. If it does, is that just a path with spaces? Or is it a command-line with arguments? blurb now handles all these cases.
1 parent 6508f25 commit 15a4cd5
Copy full SHA for 15a4cd5

File tree

Expand file treeCollapse file tree

1 file changed

+15
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+15
-1
lines changed

‎blurb/blurb.py

Copy file name to clipboardExpand all lines: blurb/blurb.py
+15-1Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import math
5555
import os
5656
import re
57+
import shlex
5758
import shutil
5859
import subprocess
5960
import 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()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.