Exit code of command substitution in bash local variable assignment [duplicate]
问题 This question already has answers here : Why does “local” sweep the return code of a command? (2 answers) Closed 3 years ago . How can I check the exit code of a command substitution in bash if the assignment is to a local variable in a function? Please see the following examples. The second one is where I want to check the exit code. Does someone have a good work-around or correct solution for this? $ function testing { test="$(return 1)"; echo $?; }; testing 1 $ function testing { local