Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes for paths and GOPATH with spaces #1374

Merged
merged 2 commits into from
Jul 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions autoload/go/def.vim
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ function! go#def#Jump(mode) abort
let $GOPATH = old_gopath
return
endif
let command = printf("%s -f=%s -o=%s -t", bin_path, fname, go#util#OffsetCursor())
let command = printf("%s -f=%s -o=%s -t", go#util#Shellescape(bin_path),
\ go#util#Shellescape(fname), go#util#OffsetCursor())
let out = go#util#System(command)
if exists("l:tmpname")
call delete(l:tmpname)
Expand Down Expand Up @@ -164,7 +165,7 @@ function! go#def#jump_to_declaration(out, mode, bin_name) abort
endif

" open the file and jump to line and column
exec cmd filename
exec cmd fnameescape(filename)
endif
endif
call cursor(line, col)
Expand Down
4 changes: 2 additions & 2 deletions autoload/go/doc.vim
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function! go#doc#Open(newmode, mode, ...) abort
return
endif

let command = printf("%s %s", bin_path, join(a:000, ' '))
let command = printf("%s %s", go#util#Shellescape(bin_path), join(a:000, ' '))
let out = go#util#System(command)
else
let out = s:gogetdoc(0)
Expand Down Expand Up @@ -137,7 +137,7 @@ function! s:gogetdoc(json) abort
return -1
endif

let cmd = [bin_path]
let cmd = [go#util#Shellescape(bin_path)]

let offset = go#util#OffsetCursor()
let fname = expand("%:p:gs!\\!/!")
Expand Down
1 change: 1 addition & 0 deletions autoload/go/fmt.vim
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ function! s:fmt_cmd(bin_name, source, target)
endif

" start constructing the command
let bin_path = go#util#Shellescape(bin_path)
let cmd = [bin_path]
call add(cmd, "-w")

Expand Down
2 changes: 1 addition & 1 deletion autoload/go/impl.vim
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function! go#impl#Impl(...) abort
return
endif

let result = go#util#System(printf("%s '%s' '%s'", binpath, recv, iface))
let result = go#util#System(join(go#util#Shelllist([binpath, recv, iface], ' ')))
if go#util#ShellError() != 0
call go#util#EchoError(result)
return
Expand Down
3 changes: 2 additions & 1 deletion autoload/go/keyify.vim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ function! go#keyify#Keyify()
endif

" Get result of command as json, that contains `start`, `end` and `replacement`
let command = printf("%s -json %s:#%s", bin_path, fname, go#util#OffsetCursor())
let command = printf("%s -json %s:#%s", go#util#Shellescape(bin_path),
\ go#util#Shellescape(fname), go#util#OffsetCursor())
let output = go#util#System(command)
silent! let result = json_decode(output)

Expand Down
3 changes: 2 additions & 1 deletion autoload/go/lint.vim
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ function! go#lint#Golint(...) abort
if empty(bin_path)
return
endif
let bin_path = go#util#Shellescape(bin_path)

if a:0 == 0
let out = go#util#System(bin_path)
Expand Down Expand Up @@ -188,7 +189,7 @@ function! go#lint#Errcheck(...) abort
echon "vim-go: " | echohl Identifier | echon "errcheck analysing ..." | echohl None
redraw

let command = bin_path . ' -abspath ' . import_path
let command = go#util#Shellescape(bin_path) . ' -abspath ' . import_path
let out = go#tool#ExecuteInDir(command)

let l:listtype = "quickfix"
Expand Down
3 changes: 2 additions & 1 deletion autoload/go/tags.vim
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func s:create_cmd(args) abort
if empty(bin_path)
return {'err': "gomodifytags does not exist"}
endif
let bin_path = go#util#Shellescape(bin_path)

let l:start = a:args.start
let l:end = a:args.end
Expand All @@ -127,7 +128,7 @@ func s:create_cmd(args) abort
" start constructing the command
let cmd = [bin_path]
call extend(cmd, ["-format", "json"])
call extend(cmd, ["-file", a:args.fname])
call extend(cmd, ["-file", go#util#Shellescape(a:args.fname)])
call extend(cmd, ["-transform", l:modifytags_transform])

if l:offset != 0
Expand Down