Calling the function system("<command>")
or systemlist("<command>")
retrieves the stdout output from a shell call to <command>
. How can I retrieve the exit status of that command?
For example, I would like to do something like this:
let output = system_call_with_exit_status("my_shell_command")
let stdout = output[0]
let exit_status = output[1]
if (exit_status != 0)
echo output
endif
The intention is to print the output from my_shell_command
only if the command gives a non-zero exit status.
:h v:shell_error