patch 7.4.1996
Problem: Capturing the output of a command takes a few commands.
Solution: Add evalcmd().
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 2e6e08a..4b55f91 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1961,6 +1961,7 @@
empty({expr}) Number |TRUE| if {expr} is empty
escape({string}, {chars}) String escape {chars} in {string} with '\'
eval({string}) any evaluate {string} into its value
+evalcmd({command}) String execute {command} and get the output
eventhandler() Number |TRUE| if inside an event handler
executable({expr}) Number 1 if executable {expr} exists
exepath({expr}) String full path of the command {expr}
@@ -3231,6 +3232,15 @@
them. Also works for |Funcref|s that refer to existing
functions.
+evalcmd({command}) *evalcmd()*
+ Execute Ex {command} and return the output as a string. This
+ is equivalent to: >
+ redir => var
+ {command}
+ redir END
+< To get a list of lines use: >
+ split(evalcmd(cmd), "\n")
+
eventhandler() *eventhandler()*
Returns 1 when inside an event handler. That is that Vim got
interrupted while waiting for the user to type a character,