Ensure that scripts don't swallow errors either#26
Ensure that scripts don't swallow errors either#26dabrahams wants to merge 3 commits intoSomeRandomiOSDev:mainfrom
Conversation
84ef5af to
bf99b61
Compare
|
As I was attempting to do the same thing for |
|
An initial compromise step might be to accept this PR without the changes to Update: the latest commit reverts the changes to |
Its structure sort of depended on continuing in the face of errors, even though the way it works is buggy. That needs to be resolved by @SomeRandomiOSDev.
| comparison=$("$(dirname "$0")/versions.sh" "$VERSION" "0.37.0"; echo $?) | ||
|
|
||
| if [ $? -ge 0 ]; then | ||
| if [ "$comparison" -ge 0 ]; then |
There was a problem hiding this comment.
It shouldn't be necessary to do things in this way given how the versions.sh script exits, at least in theory. Are you not seeing this in your testing?
There was a problem hiding this comment.
Maybe you could state your reasoning?
Here's mine: this script is using -e -o pipefail so it will exit with an error when any command it issues has a nonzero status, and versions.sh “returns” -1, 0, or 1 in its status code. If it exits with code -1, -e will cause this script to interpret it as a failure and exit immediately instead of continuing with the else clause... right? And your intention was that the else clause be reachable if versions.sh returns -1, right?
|
@dabrahams Good callouts. I hesitate to re-write these scripts in Swift just given how much of a pain it is to invoke terminal commands from Swift. As you pointed out, however, the error model for bash scripts is pretty terrible, so I guess it's a matter of picking a poison. I'll take a deeper look at these scripts overall but for the time being I'd like to keep them as is |
The principled alternative is to use @SomeRandomiOSDev how does that approach sound to you? |
No description provided.