Skip to content

Commit

Permalink
Ensure the exit code is 0 on success and 1 on error
Browse files Browse the repository at this point in the history
  • Loading branch information
lmoureaux committed Jan 4, 2024
1 parent caf1864 commit 88a0691
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions check-versions.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
#!/bin/sh

# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: Tobias Rehbein <[email protected]>
# SPDX-FileCopyrightText: Tobias Rehbein <[email protected]>
# SPDX-FileCopyrightText: Louis Moureaux <[email protected]>

# Checks that the version numbers in the index file match those in the
# modpacks.

IFS='|'
jq -r '.modpacks[] | "\(.name)|\(.version)|\(.url)"' index.json \
| while read NAME VERSION URL; do
RVERSION=$({ if $(echo "$URL" | grep -q '^http'); then
curl -s "$URL"
else
cat "$URL"
fi } | jq -r '.info.version')

[ "$VERSION" != "$RVERSION" ] \
&& echo "Version mismatch for \"$NAME\": index $VERSION; remote $RVERSION"
done
| {
STATUS=0
while read NAME VERSION URL; do
RVERSION=$({ if $(echo "$URL" | grep -q '^http'); then
curl -s "$URL"
else
cat "$URL"
fi } | jq -r '.info.version')

[ "$VERSION" != "$RVERSION" ] \
&& STATUS=1 \
&& echo "Version mismatch for \"$NAME\": index $VERSION; remote $RVERSION"
done
exit $STATUS
}

0 comments on commit 88a0691

Please sign in to comment.