Here's a C code snippet that will cause segfault:// segfault.c#include <string.h>int main(){    memset((char *)0x0, 1, 100);    return 1;}Compile it with:gcc segfault.c -o segfaultIf executed from bash:$ ./segfaultSegmentation fault (core dumped)Now I wrapped the call inside a bash script. There are three consecutive attempts. I want to get the error output inside the variable ret and display it.#!/bin/bash# segfault.shret=`./segfault 2>&1`echo 1)  $retret=`eval ./segfault 2>&1`echo 2)  $retret=`eval ./segfault 2>&1 | cat`echo 3)  $retIf I execute the script from bash:1) 2) 3)  ./segfault.sh: line 7: 28814 Segmentation fault (core dumped) ./segfaultClearly, only the third form of invocation works. My question is, why couldn't the first two forms capture the error output?
Redirecting standard error output to bash variable
bash;io redirection;stderr