From 7f64092361472e12de85f945884445e0e2274846 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 1 Sep 2015 19:07:49 +0200 Subject: [PATCH] [vim-interaction plugin] Escaping special chars in file names and simplifying code. --- .../vim-interaction.plugin.zsh | 22 ++++--------------- 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/plugins/vim-interaction/vim-interaction.plugin.zsh b/plugins/vim-interaction/vim-interaction.plugin.zsh index b0b9414c..b774be34 100644 --- a/plugins/vim-interaction/vim-interaction.plugin.zsh +++ b/plugins/vim-interaction/vim-interaction.plugin.zsh @@ -4,17 +4,6 @@ # 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 { if [[ $# == 0 ]]; then @@ -48,13 +37,10 @@ EOH if [[ ${before#:} != $before && ${before%} == $before ]]; then before="$before" fi - local files="" - for f in $@ - do - files="$files $(resolveFile $f)" - done - if [[ -n $files ]]; then - files=':args! '"$files" + local files + if [[ $# -gt 0 ]]; then + # absolute path of files resolving symlinks (:A) and quoting special chars (:q) + files=':args! '"${@:A:q}" fi cmd="$before$files$after" gvim --remote-send "$cmd"