I have a Bash script fragment like this:
local SOME_VAR=$( first_command | second_command )
SECOND_COMMAND_EXIT_CODE=$?
But SECOND_COMMAND_EXIT_CODE is always zero even when second_command fails. It is also worth noting that second_command outputs multiple lines of text.
Is there a way to capture all the output of second_command in a variable and also capture its exit code in another variable?
 
    