From 1150e89b65c56029fd7bac5e44e830887dd6a247 Mon Sep 17 00:00:00 2001 From: Laurent Bachelier Date: Wed, 17 Sep 2014 21:48:46 +0200 Subject: [PATCH] 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. --- weboob/applications/webcontentedit/webcontentedit.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/weboob/applications/webcontentedit/webcontentedit.py b/weboob/applications/webcontentedit/webcontentedit.py index 960ce970..13df118d 100644 --- a/weboob/applications/webcontentedit/webcontentedit.py +++ b/weboob/applications/webcontentedit/webcontentedit.py @@ -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()])))