Skip to content

Issue #162: make blurb sophisticated about EDITOR. #206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion blurb/blurb.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import math
import os
import re
import shlex
import shutil
import subprocess
import sys
Expand Down Expand Up @@ -893,8 +894,21 @@ def init_tmp_with_template():

init_tmp_with_template()

# We need to be clever about EDITOR.
# On the one hand, it might be a legitimate path to an
# executable containing spaces.
# On the other hand, it might be a partial command-line
# with options.
if shutil.which(editor):
args = [editor]
else:
args = list(shlex.split(editor))
if not shutil.which(args[0]):
sys.exit("Invalid GIT_EDITOR / EDITOR value: {}".format(editor))
args.append(tmp_path)

while True:
subprocess.run([editor, tmp_path])
subprocess.run(args)

failure = None
blurb = Blurbs()
Expand Down