Skip to content

Instantly share code, notes, and snippets.

@mhinz
Created Oct 13, 2017
Embed
What would you like to do?
#!/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