Given:
declare foo="$(some_script_that_fails_with_exit_code_200)"
[ $? == 0 ] && echo 'yes'
Will always echo yes because the return code is the code from the declare command and not from the subshell. The proper way to write this would be:
declare foo
foo="$(some_script_that_fails_with_exit_code_200)"
[ $? == 0 ] && echo 'yes'
It would be great if there was a check that could catch this.
Given:
Will always echo
yesbecause the return code is the code from thedeclarecommand and not from the subshell. The proper way to write this would be:It would be great if there was a check that could catch this.