if 'r ! . test.sh' == 'yes'
That syntax is nonsense. First, the :r !{cmd}
is reading the output of {cmd}
into the current buffer, which is probably not what you want. To get this into a variable, use :let output = system('test.sh')
, or directly compare via:
if system('test.sh') == 'yes'
Note that comparing the output (especially if it's a true / false or success / failure boolean value as suggested by your question) is unusual. Rather, the script's exit status is checked (e.g. with commands like grep
). You can get that in Vim via the special v:shell_error
variable (which is filled by both system()
and :r !
).