summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale.vim11
-rw-r--r--autoload/ale/engine.vim8
-rw-r--r--autoload/ale/path.vim2
3 files changed, 16 insertions, 5 deletions
diff --git a/autoload/ale.vim b/autoload/ale.vim
index c8fbfdfc..189f1e46 100644
--- a/autoload/ale.vim
+++ b/autoload/ale.vim
@@ -123,3 +123,14 @@ function! ale#Var(buffer, variable_name) abort
return getbufvar(str2nr(a:buffer), l:full_name, g:[l:full_name])
endfunction
+
+" Escape a string suitably for each platform.
+" shellescape() does not work on Windows.
+function! ale#Escape(str) abort
+ if fnamemodify(&shell, ':t') ==? 'cmd.exe'
+ " FIXME: Fix shell escaping for Windows.
+ return fnameescape(a:str)
+ else
+ return shellescape(a:str)
+ endif
+endfunction
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim
index 339f7ee9..486bdd4f 100644
--- a/autoload/ale/engine.vim
+++ b/autoload/ale/engine.vim
@@ -480,14 +480,14 @@ function! ale#engine#FormatCommand(buffer, command) abort
" file.
if l:command =~# '%s'
let l:filename = fnamemodify(bufname(a:buffer), ':p')
- let l:command = substitute(l:command, '%s', '\=shellescape(l:filename)', 'g')
+ let l:command = substitute(l:command, '%s', '\=ale#Escape(l:filename)', 'g')
endif
if l:command =~# '%t'
" Create a temporary filename, <temp_dir>/<original_basename>
" The file itself will not be created by this function.
let l:temporary_file = s:TemporaryFilename(a:buffer)
- let l:command = substitute(l:command, '%t', '\=shellescape(l:temporary_file)', 'g')
+ let l:command = substitute(l:command, '%t', '\=ale#Escape(l:temporary_file)', 'g')
endif
" Finish formatting so %% becomes %.
@@ -529,7 +529,7 @@ function! s:RunJob(options) abort
" in the shell. We'll write out the file to a temporary file,
" and then read it back in, in the shell.
let l:temporary_file = s:TemporaryFilename(l:buffer)
- let l:command = l:command . ' < ' . shellescape(l:temporary_file)
+ let l:command = l:command . ' < ' . ale#Escape(l:temporary_file)
endif
if s:CreateTemporaryFileForJob(l:buffer, l:temporary_file)
@@ -636,7 +636,7 @@ function! s:RunJob(options) abort
" Run a command synchronously if this test option is set.
let s:job_info_map[l:job_id].output = systemlist(
\ type(l:command) == type([])
- \ ? join(l:command[0:1]) . ' ' . shellescape(l:command[2])
+ \ ? join(l:command[0:1]) . ' ' . ale#Escape(l:command[2])
\ : l:command
\)
call s:HandleExit(l:job)
diff --git a/autoload/ale/path.vim b/autoload/ale/path.vim
index 26da9e24..88aa482d 100644
--- a/autoload/ale/path.vim
+++ b/autoload/ale/path.vim
@@ -47,7 +47,7 @@ endfunction
" Output 'cd <directory> && '
" This function can be used changing the directory for a linter command.
function! ale#path#CdString(directory) abort
- return 'cd ' . shellescape(a:directory) . ' && '
+ return 'cd ' . ale#Escape(a:directory) . ' && '
endfunction
" Output 'cd <buffer_filename_directory> && '