I am trying to write simple function which runs a shell command and prints the result into vims shell output window, this here is a basic version of the function which does work:
function defined in ~/.vimrc
function! Runphp() let s:runphp='cat /tmp/php_snippet | php' echo(system(s:runphp)) endfunction file /tmp/php_snippet
<?php $a = ['apple', 'orange', 'bannana', 'pear']; print_r($a); If I run :call Runphp() vim prints the result of the executed PHP in the result window, all good.
The problem occurs where the <?php tag doesn't already exist in /tmp/php_snippet i.e.
file /tmp/php_snippet looks like this:
$a = ['apple', 'orange', 'bannana', 'pear']; print_r($a); and I try to inject <?php as part of the shell command, i.e.
function! Runphp() let s:runphp='{ echo "<?php"; cat /tmp/php_snippet } | php' echo(system(s:runphp)) endfunction If I :call Runphp() now, vim returns
Error detected while processing function Runphp:
line 3:
E484: Can't open file /tmp/vReTqKG/9
How can I deal with this error so I can get this extra <?php injected into the shell command?