Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that scripts don't swallow errors either #26

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions scripts/carthage.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/usr/bin/env bash
#!/usr/bin/env bash -e -o pipefail
#
# Needed to circumvent an issue with Carthage version < 0.37.0: https://github.com/Carthage/Carthage/issues/3019
#
# carthage.sh
# Usage example: ./carthage.sh build --platform iOS

VERSION="$(carthage version)"
"$(dirname "$0")/versions.sh" "$VERSION" "0.37.0"
comparison=$("$(dirname "$0")/versions.sh" "$VERSION" "0.37.0"; echo $?)

if [ $? -ge 0 ]; then
if [ "$comparison" -ge 0 ]; then
Comment on lines +9 to +11
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

@dabrahams dabrahams Nov 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

# Carthage version is greater than or equal to 0.37.0 meaning we can use the --use-xcframeworks flag
carthage "$@" --use-xcframeworks
else
Expand Down
2 changes: 1 addition & 1 deletion scripts/findproject.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bash -e -o pipefail
#
# xcframework.sh
# Usage example: ./findproject.sh --project-name <project_name>
Expand Down
2 changes: 1 addition & 1 deletion scripts/printformat.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bash -e -o pipefail
#
# https://gist.github.com/SomeRandomiOSDev/798406a4a15f6b5d78b010599865c04f
#
Expand Down
2 changes: 1 addition & 1 deletion scripts/resolvepath.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bash -e -o pipefail
#
# resolvepath.sh
# Usage example: ./resolvepath.sh "./some/random/path/../../"
Expand Down
2 changes: 1 addition & 1 deletion scripts/versions.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bash -e -o pipefail
#
# versions.sh
# Usage example: ./versions.sh "1.4.15" "1.7.0"
Expand Down
2 changes: 1 addition & 1 deletion scripts/xcframework.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bash -e -o pipefail
#
# xcframework.sh
# Usage example: ./xcframework.sh --output <some_path>/<name>.xcframework
Expand Down