[CI] Add curly braces check (#5809)

Update shellcheck and shfmt to the latest version.

Fixes <https://github.com/koreader/koreader/issues/5152>.

Btw, you can apply shellcheck suggestions with a command like:

```
shellcheck --include=SC2250 -f diff *.sh | git apply
```
This commit is contained in:
Frans de Jonge
2020-02-02 20:35:21 +01:00
committed by GitHub
parent 283187efb7
commit 668eee97fa
22 changed files with 124 additions and 124 deletions

View File

@@ -3,32 +3,32 @@
# Converts the return of "sh wrapper.sh $@" into Lua format.
CURRENT_DIR=$(dirname "$0")
sh "$CURRENT_DIR/wrapper.sh" "$@" >/dev/null 2>&1 &
sh "${CURRENT_DIR}/wrapper.sh" "$@" >/dev/null 2>&1 &
JOB_ID=$!
while true; do
if ps -p $JOB_ID >/dev/null 2>&1; then
if ps -p ${JOB_ID} >/dev/null 2>&1; then
# Unblock f:read().
echo
else
wait $JOB_ID
wait ${JOB_ID}
EXIT_CODE=$?
if [ "$EXIT_CODE" -eq "255" ]; then
if [ "${EXIT_CODE}" -eq "255" ]; then
TIMEOUT="true"
else
TIMEOUT="false"
fi
if [ "$EXIT_CODE" -eq "127" ]; then
if [ "${EXIT_CODE}" -eq "127" ]; then
BADCOMMAND="true"
else
BADCOMMAND="false"
fi
echo "return { \
result = $EXIT_CODE, \
timeout = $TIMEOUT, \
bad_command = $BADCOMMAND, \
result = ${EXIT_CODE}, \
timeout = ${TIMEOUT}, \
bad_command = ${BADCOMMAND}, \
}"
exit 0
fi

View File

@@ -5,35 +5,35 @@
# to start, this script returns 127. If the command is timed out, this script
# returns 255. Otherwise the return value of the command will be returned.
echo "TIMEOUT in environment: $TIMEOUT"
echo "TIMEOUT in environment: ${TIMEOUT}"
if [ -z "$TIMEOUT" ]; then
if [ -z "${TIMEOUT}" ]; then
TIMEOUT=3600
fi
echo "Timeout has been set to $TIMEOUT seconds"
echo "Timeout has been set to ${TIMEOUT} seconds"
echo "Will start command $*"
echo "$@" | nice -n 19 sh &
JOB_ID=$!
echo "Job id: $JOB_ID"
echo "Job id: ${JOB_ID}"
for i in $(seq 1 1 $TIMEOUT); do
if ps -p $JOB_ID >/dev/null 2>&1; then
for i in $(seq 1 1 ${TIMEOUT}); do
if ps -p ${JOB_ID} >/dev/null 2>&1; then
# Job is still running.
sleep 1
ROUND=$(printf "%s" "$i" | tail -c 1)
if [ "$ROUND" -eq "0" ]; then
echo "Job $JOB_ID is still running ... waited for $i seconds."
ROUND=$(printf "%s" "${i}" | tail -c 1)
if [ "${ROUND}" -eq "0" ]; then
echo "Job ${JOB_ID} is still running ... waited for ${i} seconds."
fi
else
wait $JOB_ID
wait ${JOB_ID}
exit $?
fi
done
echo "Command $* has timed out"
kill -9 $JOB_ID
kill -9 ${JOB_ID}
exit 255