This question already has an answer here:
I am setting a variable like this:
I want to check the exit code (
$?) of my command afterwards. Checking
$? like this always returns
0 because it successfully set the variable to the output of the command.
Is it possible to get the return value of