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.
This commit is contained in:
parent
b583b8d8f4
commit
1150e89b65
1 changed files with 3 additions and 1 deletions
|
|
@ -21,6 +21,7 @@
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
import codecs
|
import codecs
|
||||||
|
from distutils.spawn import find_executable
|
||||||
|
|
||||||
from weboob.core.bcall import CallErrors
|
from weboob.core.bcall import CallErrors
|
||||||
from weboob.capabilities.content import CapContent, Revision
|
from weboob.capabilities.content import CapContent, Revision
|
||||||
|
|
@ -73,7 +74,8 @@ class WebContentEdit(ReplApplication):
|
||||||
|
|
||||||
params = ''
|
params = ''
|
||||||
editor = os.environ.get('EDITOR', 'vim')
|
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'
|
params = '-p'
|
||||||
os.system("%s %s %s" % (editor, params, ' '.join(['"%s"' % path.replace('"', '\\"') for path in paths.iterkeys()])))
|
os.system("%s %s %s" % (editor, params, ' '.join(['"%s"' % path.replace('"', '\\"') for path in paths.iterkeys()])))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue