From a31c98c9ef1347f972c2b0165d870420c4506e3d Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Mon, 31 Dec 2012 19:53:54 -0500 Subject: [PATCH] Properly escape temp paths on Windows This was leading to a cryptic error message referencing \U (as in "C:\Users"). Addresses half of #22. --- plugin/foreplay.vim | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/plugin/foreplay.vim b/plugin/foreplay.vim index a61987d..4cf0b3d 100644 --- a/plugin/foreplay.vim +++ b/plugin/foreplay.vim @@ -18,7 +18,7 @@ augroup foreplay_file_type augroup END " }}}1 -" Shell escaping {{{1 +" Escaping {{{1 function! foreplay#shellesc(arg) abort if a:arg =~ '^[A-Za-z0-9_/.-]\+$' @@ -35,6 +35,10 @@ function! foreplay#shellesc(arg) abort endif endfunction +function! s:str(string) + return '"' . escape(a:string, '"\') . '"' +endfunction + " }}}1 " Completion {{{1 @@ -290,14 +294,14 @@ function! s:oneoff.eval(expr, ns) dict abort call writefile([], s:oneoff_err, 'b') let command = g:java_cmd.' -cp '.shellescape(self.classpath).' clojure.main -e ' . \ foreplay#shellesc( - \ '(binding [*out* (java.io.FileWriter. "'.s:oneoff_out.'")' . - \ ' *err* (java.io.FileWriter. "'.s:oneoff_err.'")]' . + \ '(binding [*out* (java.io.FileWriter. '.s:str(s:oneoff_out).')' . + \ ' *err* (java.io.FileWriter. '.s:str(s:oneoff_err).')]' . \ ' (try' . - \ ' (require ''clojure.repl) '.ns.'(spit "'.s:oneoff_pr.'" (pr-str (eval (read-string (slurp "'.s:oneoff_in.'")))))' . + \ ' (require ''clojure.repl) '.ns.'(spit '.s:str(s:oneoff_pr).' (pr-str (eval (read-string (slurp '.s:str(s:oneoff_in).')))))' . \ ' (catch Exception e' . \ ' (spit *err* (.toString e))' . - \ ' (spit "'.s:oneoff_ex.'" (class e))' . - \ ' (spit "'.s:oneoff_stk.'" (apply str (interpose "\n" (.getStackTrace e))))))' . + \ ' (spit '.s:str(s:oneoff_ex).' (class e))' . + \ ' (spit '.s:str(s:oneoff_stk).' (apply str (interpose "\n" (.getStackTrace e))))))' . \ ' nil)') let wtf = system(command) let result = {}