Code example:
A(){ local return_value="$(bash -c "exit 1")" echo $? } function A: returns 0 - even though obviously the return value is 1. B(){ return_value="$(bash -c "exit 1")" echo $? }function B: returns 1 - as expected, the only difference to function A being not using a local variable to store the value.
Best regards, A happy bash user