bug: Fix incorrect return code handling
requested to merge Javinator9889/download-secure-files:dev/fix-bash-incorrect-error-handling into main
-
Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA
The $?
construct refers to the latest command return code. The way it was written, $?
was checking the echo
's return code instead of the go build
one - which was actually the command to check. echo
seldom fails so potential build errors were being masked.
$ false
$ echo $?
1
$ bad_rc() { false; echo "building ..."; if [ $? -ne 0 ]; then echo "build failed"; return 1; fi; }
$ bad_rc
building ...
NOTE: This MR is a duplicate of !14 (closed). I created it from a new account because I forgot I still got mine
😅
Edited by 🤖 GitLab Bot 🤖