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

Increase compatibility with tcsh #869

Merged
merged 2 commits into from
Jun 3, 2016
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
1 change: 1 addition & 0 deletions autoload/go/cmd.vim
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ function! go#cmd#Test(bang, compile, ...)
if a:0
" expand all wildcards(i.e: '%' to the current file name)
let goargs = map(copy(a:000), "expand(v:val)")
let goargs = go#util#Shelllist(goargs, 1)

call extend(args, goargs, 1)
else
Expand Down
3 changes: 2 additions & 1 deletion autoload/go/doc.vim
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ function! go#doc#Open(newmode, mode, ...)

let offset = go#util#OffsetCursor()
let fname = expand("%:p")
let pos = shellescape(fname.':#'.offset)

let command = printf("%s -pos %s:#%s", bin_path, fname, offset)
let command = printf("%s -pos %s", bin_path, pos)

let out = go#util#System(command)
if go#util#ShellError() != 0
Expand Down
3 changes: 2 additions & 1 deletion autoload/go/guru.vim
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ func! s:RunGuru(mode, format, selected, needs_scope) range abort
endif

" this is our final command
let command .= printf(' %s %s:%s', a:mode, shellescape(filename), pos)
let filename .= ':'.pos
let command .= printf(' %s %s', a:mode, shellescape(filename))

let old_gopath = $GOPATH
let $GOPATH = go#path#Detect()
Expand Down
17 changes: 10 additions & 7 deletions autoload/go/tool.vim
Original file line number Diff line number Diff line change
@@ -1,38 +1,41 @@
function! go#tool#Files()
if go#util#IsWin()
let command = 'go list -f "{{range $f := .GoFiles}}{{$.Dir}}\{{$f}}{{printf \"\n\"}}{{end}}{{range $f := .CgoFiles}}{{$.Dir}}\{{$f}}{{printf \"\n\"}}{{end}}"'
let format = '{{range $f := .GoFiles}}{{$.Dir}}\{{$f}}{{printf \"\n\"}}{{end}}{{range $f := .CgoFiles}}{{$.Dir}}\{{$f}}{{printf \"\n\"}}{{end}}'
else
let command = "go list -f '{{range $f := .GoFiles}}{{$.Dir}}/{{$f}}{{printf \"\\n\"}}{{end}}{{range $f := .CgoFiles}}{{$.Dir}}/{{$f}}{{printf \"\\n\"}}{{end}}'"
let format = "{{range $f := .GoFiles}}{{$.Dir}}/{{$f}}{{printf \"\\n\"}}{{end}}{{range $f := .CgoFiles}}{{$.Dir}}/{{$f}}{{printf \"\\n\"}}{{end}}"
endif
let command = 'go list -f '.shellescape(format)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already a lot of escaping above, do you think this is necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately the escaping is necessary. The escaping above only escapes for the string, but we need to escape for the shell, too.

let out = go#tool#ExecuteInDir(command)
return split(out, '\n')
endfunction

function! go#tool#Deps()
if go#util#IsWin()
let command = 'go list -f "{{range $f := .Deps}}{{$f}}{{printf \"\n\"}}{{end}}"'
let format = '{{range $f := .Deps}}{{$f}}{{printf \"\n\"}}{{end}}'
else
let command = "go list -f $'{{range $f := .Deps}}{{$f}}\n{{end}}'"
let format = "{{range $f := .Deps}}{{$f}}\n{{end}}"
endif
let command = 'go list -f '.shellescape(format)
let out = go#tool#ExecuteInDir(command)
return split(out, '\n')
endfunction

function! go#tool#Imports()
let imports = {}
if go#util#IsWin()
let command = 'go list -f "{{range $f := .Imports}}{{$f}}{{printf \"\n\"}}{{end}}"'
let format = '{{range $f := .Imports}}{{$f}}{{printf \"\n\"}}{{end}}'
else
let command = "go list -f $'{{range $f := .Imports}}{{$f}}\n{{end}}'"
let format = "{{range $f := .Imports}}{{$f}}{{printf \"\\n\"}}{{end}}"
endif
let command = 'go list -f '.shellescape(format)
let out = go#tool#ExecuteInDir(command)
if go#util#ShellError() != 0
echo out
return imports
endif

for package_path in split(out, '\n')
let cmd = "go list -f {{.Name}} " . package_path
let cmd = "go list -f '{{.Name}}' " . shellescape(package_path)
let package_name = substitute(go#tool#ExecuteInDir(cmd), '\n$', '', '')
let imports[package_name] = package_path
endfor
Expand Down