RESULT_VARIABLE holds only result of last COMMAND when execute_process() is called with multiple commands
Consider something like
execute_process(
COMMAND command1
COMMAND command2
RESULT_VARIABLE res
OUTPUT_VARIABLE out
ERROR_VARIABLE err
)
If command1
fails but does not output anything to stderr there is no possibility to know if anything went wrong as long as command2
returns successfully.
This effectively renders the automatic piping of output from one command to the next useless, as multiple execute_process()
commands need to be used in order to be able to catch errors.
A possible solution could be to return a list as RESULT_VARIABLE, that contains the result of each individual command.