Between
:%!
exe "!..."
exe "!bash -c" shellescape(...)
I'm getting quite confused as to what exactly Vim invokes. And I suspect at some point it invokes bash -c bash ...
. Is there a way to see exactly what shell command is being called out? Does Vim ever invoke directly the command after !
, or does it always wrap the command in bash -c ...
?
I'm really trying to invoke a shell command, stored in g:cmd
, which has a %
in it, with as little overhead as possible (i.e., no bash -c bash
). It's supposed to act as a filter on the visual selection. But
exe "'<,'>!" g:cmd # Substitutes '%'
exe "'<,'>! bash -c" shellescape( g:cmd, 1 ) # Maybe wraps 2x bash around
exe "'<,'>!" shellescape( g:cmd, 1/0 ) # Bash calls g:cmd as executable -> error
'shell'
to be that. It can be a script that does whatever you want...prints the parameters passed to it, for instance.