Properly escape temp paths on Windows

This was leading to a cryptic error message referencing \U (as in
"C:\Users").  Addresses half of #22.
This commit is contained in:
Tim Pope 2012-12-31 19:53:54 -05:00
parent 23ecbe5649
commit a31c98c9ef
1 changed files with 10 additions and 6 deletions

View File

@ -18,7 +18,7 @@ augroup foreplay_file_type
augroup END augroup END
" }}}1 " }}}1
" Shell escaping {{{1 " Escaping {{{1
function! foreplay#shellesc(arg) abort function! foreplay#shellesc(arg) abort
if a:arg =~ '^[A-Za-z0-9_/.-]\+$' if a:arg =~ '^[A-Za-z0-9_/.-]\+$'
@ -35,6 +35,10 @@ function! foreplay#shellesc(arg) abort
endif endif
endfunction endfunction
function! s:str(string)
return '"' . escape(a:string, '"\') . '"'
endfunction
" }}}1 " }}}1
" Completion {{{1 " Completion {{{1
@ -290,14 +294,14 @@ function! s:oneoff.eval(expr, ns) dict abort
call writefile([], s:oneoff_err, 'b') call writefile([], s:oneoff_err, 'b')
let command = g:java_cmd.' -cp '.shellescape(self.classpath).' clojure.main -e ' . let command = g:java_cmd.' -cp '.shellescape(self.classpath).' clojure.main -e ' .
\ foreplay#shellesc( \ foreplay#shellesc(
\ '(binding [*out* (java.io.FileWriter. "'.s:oneoff_out.'")' . \ '(binding [*out* (java.io.FileWriter. '.s:str(s:oneoff_out).')' .
\ ' *err* (java.io.FileWriter. "'.s:oneoff_err.'")]' . \ ' *err* (java.io.FileWriter. '.s:str(s:oneoff_err).')]' .
\ ' (try' . \ ' (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' . \ ' (catch Exception e' .
\ ' (spit *err* (.toString e))' . \ ' (spit *err* (.toString e))' .
\ ' (spit "'.s:oneoff_ex.'" (class e))' . \ ' (spit '.s:str(s:oneoff_ex).' (class e))' .
\ ' (spit "'.s:oneoff_stk.'" (apply str (interpose "\n" (.getStackTrace e))))))' . \ ' (spit '.s:str(s:oneoff_stk).' (apply str (interpose "\n" (.getStackTrace e))))))' .
\ ' nil)') \ ' nil)')
let wtf = system(command) let wtf = system(command)
let result = {} let result = {}