I want to have a function in my .vimrc that will run a bash script, check the output, and do different things depending on the bash script output.
Currently, my bash script returns "yes". My vim function is then:
function! Callscript()
if 'r ! . test.sh' == 'yes'
echom "returned yes"
else
echom "returned something else"
endif
endfunction
This will always print "returned something else". When I run the command ':r ! . test.sh', it returns:
test.sh: line 5: return: yes: numeric argument required
I didn't see anything in :help r! that mentioned doing anything extra to get the return values, but I tried:
if 'r ! . test.sh'.return == 'yes'
if 'r ! . test.sh':return == 'yes'
which gave me errors. I have tried using system, but could not get that to work. The most obvious approach I tried with system was:
if system('r ! . test.sh') == 'yes'
When I try system('. test.sh') in the editor, it tells me system is not an editor command.
How can I access the return value of the bash script so that I can use it in my vim function?