[vim-interaction plugin] Escaping special chars in file names and simplifying code.

This commit is contained in:
Marc Cornellà 2015-09-01 19:07:49 +02:00 committed by Igor Dejanovic
parent ba5fd57c1f
commit 7f64092361
1 changed files with 4 additions and 18 deletions

View File

@ -4,17 +4,6 @@
# Derek Wyatt (derek@{myfirstnamemylastname}.org # Derek Wyatt (derek@{myfirstnamemylastname}.org
# #
function resolveFile
{
if [ -f "$1" ]; then
echo $(readlink -f "$1")
elif [[ "${1#/}" == "$1" ]]; then
echo "$PWD/$1"
else
echo $1
fi
}
function callvim function callvim
{ {
if [[ $# == 0 ]]; then if [[ $# == 0 ]]; then
@ -48,13 +37,10 @@ EOH
if [[ ${before#:} != $before && ${before%<cr>} == $before ]]; then if [[ ${before#:} != $before && ${before%<cr>} == $before ]]; then
before="$before<cr>" before="$before<cr>"
fi fi
local files="" local files
for f in $@ if [[ $# -gt 0 ]]; then
do # absolute path of files resolving symlinks (:A) and quoting special chars (:q)
files="$files $(resolveFile $f)" files=':args! '"${@:A:q}<cr>"
done
if [[ -n $files ]]; then
files=':args! '"$files<cr>"
fi fi
cmd="$before$files$after" cmd="$before$files$after"
gvim --remote-send "$cmd" gvim --remote-send "$cmd"