mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
[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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user