In my project I have the following snippet:
local output="$(bash "${1##*/}")"
echo "$?"
This always prints zero due to local, however, removing local causes the $? variable to behave correctly: which is to assume the exit code from the subshell.
My question is: how I can keep this variable local whilst also capturing the exit value?
shellcheckwill not only catch this issue but suggest the solution at unix.stackexchange.com/a/281749/24718! – Waleed Khan 6 hours ago