Skip to content

Instantly share code, notes, and snippets.

@mkmik
Last active February 23, 2018 23:32
Show Gist options
  • Save mkmik/744ab3244f974715d805e25e150fb7eb to your computer and use it in GitHub Desktop.
Save mkmik/744ab3244f974715d805e25e150fb7eb to your computer and use it in GitHub Desktop.
#!/bin/bash
set -euo pipefail
# go-vim checks for flags like srcdir
echo -- "$@" | grep -- --help && exec goreturns "$@"
tmp_dir="$(mktemp -d)"
cleanup() {
rm -rf "${tmp_dir}"
}
trap cleanup EXIT
our_tmp="${tmp_dir}"/file.go
args=("$@")
vim_tmp=${args[${#args[@]}-1]}
args[${#args[@]}-1]="${our_tmp}"
cp "${vim_tmp}" "${our_tmp}"
$(dirname "$0")/goreturns "${args[@]}" 2>/tmp/err
cp "${our_tmp}" "${vim_tmp}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment