Commit 1150e89b authored by Laurent Bachelier's avatar Laurent Bachelier 🐧

webcontentedit: Better checks for vim usage

Using a full path would not detect vim (/usr/bin/vim).
Also, we can detect if EDITOR=vi but the vi is a symlink to vim.
parent b583b8d8
......@@ -21,6 +21,7 @@
import os
import tempfile
import codecs
from distutils.spawn import find_executable
from weboob.core.bcall import CallErrors
from weboob.capabilities.content import CapContent, Revision
......@@ -73,7 +74,8 @@ class WebContentEdit(ReplApplication):
params = ''
editor = os.environ.get('EDITOR', 'vim')
if editor == 'vim':
# check cases where /usr/bin/vi is a symlink to vim
if 'vim' in (os.path.basename(editor), os.path.basename(os.path.realpath(find_executable(editor) or '/')).replace('.nox', '')):
params = '-p'
os.system("%s %s %s" % (editor, params, ' '.join(['"%s"' % path.replace('"', '\\"') for path in paths.iterkeys()])))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment