Skip to content

Instantly share code, notes, and snippets.

@mhinz
Created October 13, 2017 23:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhinz/ec6f0363ac083ab80613148d39b28121 to your computer and use it in GitHub Desktop.
Save mhinz/ec6f0363ac083ab80613148d39b28121 to your computer and use it in GitHub Desktop.
#!/usr/bin/env zsh
# Emulate Vim executable that simply returns its arguments.
> /tmp/vim.rb <<EOF
#!/usr/bin/env ruby
p ARGV
EOF
chmod 700 /tmp/vim.rb
VISUAL="/tmp/vim.rb -c 'first arg'"
bad() {
${=VISUAL} -c 'second arg' -- $1
}
good() {
eval "${VISUAL[@]} -c 'second arg' -- $1"
}
bad file
good file
@mhinz
Copy link
Author

mhinz commented Oct 13, 2017

$ /tmp/test.sh
["-c", "'first", "arg'", "-c", "second arg", "--", "file"]
["-c", "first arg", "-c", "second arg", "--", "file"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment