I want to run a command from a sub-bash and I need the return code from it; actually it's running a pipeline and I need the PIPESTATUS array, or at least one component.
This was my best guess and it does not work. I just get a 0. Since bash did not error it makes sense, it's just not what I need. Help?
bash -c "echo 123 | grep abc | sort; exit ${PIPESTATUS[1]}"; echo $?
0