diff options
author | C. Morgan Hamill <me@cmhamill.org> | 2018-08-30 12:44:11 -0700 |
---|---|---|
committer | C. Morgan Hamill <me@cmhamill.org> | 2018-08-30 12:44:11 -0700 |
commit | 382323d0d4c37d98bb4088e2b4541a2a62180fa5 (patch) | |
tree | db12b4b1566733a8b62e0a2747ef0d6dd8cff486 | |
parent | 2b0cfa495174a3d110b1d68c424ca7666998351d (diff) | |
download | edit-382323d0d4c37d98bb4088e2b4541a2a62180fa5.tar.gz edit-382323d0d4c37d98bb4088e2b4541a2a62180fa5.zip |
Use shell-style word-splitting on `editor`
Use `shlex.split()` on the (possibly user-provided) editor, to avoid
passing a nonsensical list to `subprocess.Popen`.
Allow use of `plugins.var.python.edit.editor = "vim -c 'set notitle'"`,
for example, which previously was passed to `subprocess.Popen` as
`["vim", "-c", "'set", "notitle'", path]`.
-rw-r--r-- | edit.py | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -13,6 +13,7 @@ import os import os.path +import shlex import subprocess import weechat @@ -24,7 +25,7 @@ def edit(data, buf, args): with open(path, "w+") as f: f.write(weechat.buffer_get_string(buf, "input")) - cmd = editor.split() + [path] + cmd = shlex.split(editor) + [path] code = subprocess.Popen(cmd).wait() if code != 0: os.remove(path) |