2
0
mirror of https://github.com/koreader/koreader synced 2024-11-18 03:25:46 +00:00

lint: fix issues reported by newer shellcheck / shfmt

This commit is contained in:
Benoit Pierre 2024-06-15 22:54:32 +02:00 committed by Frans de Jonge
parent c6f5db0f9e
commit 088ae7d4ee
8 changed files with 17 additions and 21 deletions

14
kodev
View File

@ -115,10 +115,10 @@ function setup_env() {
local ts=()
# Store list of ts at the same index
for i in "${!files[@]}"; do
local file="${files[${i}]}/koreader"
local file="${files[i]}/koreader"
if [ -d "${file}" ]; then
echo "${file} (last modified on $(stat -c %y "${file}"))"
ts[${i}]="$(stat -c %Y "${file}")"
ts[i]="$(stat -c %Y "${file}")"
fi
done
# Sort the list of ts
@ -126,15 +126,15 @@ function setup_env() {
IFS=$'\n' read -d '' -r -a sorted_ts < <(printf '%s\n' "${ts[@]}" | sort -r)
# Find the id of the most recent ts (spoiler: it's going to be the one currently targeted by this invocation of kodev)
for i in "${!ts[@]}"; do
if [ "${ts[${i}]}" == "${sorted_ts[0]}" ]; then
if [ "${ts[i]}" == "${sorted_ts[0]}" ]; then
idx="${i}"
break
fi
done
# Recap
echo "Picking the most recent one: ${files[${idx}]}/koreader"
echo "Picking the most recent one: ${files[idx]}/koreader"
fi
EMU_DIR="${files[${idx}]}/koreader"
EMU_DIR="${files[idx]}/koreader"
export EMU_DIR
}
@ -764,7 +764,7 @@ TARGET:
adb install "koreader-android-${ANDROID_ARCH}${KODEBUG_SUFFIX}-${VERSION}.apk"
assert_ret_zero $?
# there's no adb run so we do this…
adb shell monkey -p org.koreader.launcher${KODEBUG_SUFFIX/-/.} -c android.intent.category.LAUNCHER 1
adb shell monkey -p "org.koreader.launcher${KODEBUG_SUFFIX/-/.}" -c android.intent.category.LAUNCHER 1
assert_ret_zero $?
adb logcat KOReader:V k2pdfopt:V luajit-launcher:V dlopen:V "*:E"
} || echo "Failed to find adb in PATH to interact with Android device."
@ -837,7 +837,7 @@ TARGET:
capture_ctrl_c
fi
exit ${RETURN_VALUE}
exit "${RETURN_VALUE}"
;;
esac
}

View File

@ -23,4 +23,3 @@ mount -o "${MOUNT_ARGS}" -t vfat "${PARTITION}" /mnt/onboard
PARTITION=${DISK}1p1
[ -e "${PARTITION}" ] && mount -o "${MOUNT_ARGS}" -t vfat "${PARTITION}" /mnt/sd

View File

@ -1,4 +1,3 @@
#! /bin/sh
echo 0 >/sys/power/state-extended

View File

@ -12,4 +12,3 @@ sync
# Suspend to RAM.
echo mem >/sys/power/state

View File

@ -28,4 +28,3 @@ done
export -n KO_MULTIUSER
exit ${RETURN_VALUE}

View File

@ -118,7 +118,7 @@ while [ "${RETURN_VALUE}" -ne 0 ]; do
if [ "${RETURN_VALUE}" -ne 0 ] && [ "${RETURN_VALUE}" -ne ${KO_RC_RESTART} ]; then
# Increment the crash counter
# shellcheck disable=SC2003
CRASH_COUNT="$(expr ${CRASH_COUNT} + 1)"
CRASH_COUNT="$(expr "${CRASH_COUNT}" + 1)"
CRASH_TS="$(date +'%s')"
# Reset it to a first crash if it's been a while since our last crash...
# shellcheck disable=SC2003
@ -148,7 +148,7 @@ while [ "${RETURN_VALUE}" -ne 0 ]; do
bombMargin="$(expr ${FONTH} + ${FONTH} / 2)"
# With a little notice at the top of the screen, on a big gray screen of death ;).
"${KOREADER_DIR}/fbink" -q -b -c -B GRAY9 -m -y 1 "Don't Panic! (Crash n°${CRASH_COUNT} -> ${RETURN_VALUE})"
if [ ${CRASH_COUNT} -eq 1 ]; then
if [ "${CRASH_COUNT}" -eq 1 ]; then
# Warn that we're sleeping for a bit...
"${KOREADER_DIR}/fbink" -q -b -O -m -y 2 "KOReader will restart in 15 sec."
fi
@ -168,13 +168,13 @@ while [ "${RETURN_VALUE}" -ne 0 ]; do
echo "!!!!"
echo "Uh oh, something went awry... (Crash n°${CRASH_COUNT}: $(date +'%x @ %X'))"
} >>crash.log 2>&1
if [ ${CRASH_COUNT} -lt 5 ] && [ "${ALWAYS_ABORT}" = "false" ]; then
if [ "${CRASH_COUNT}" -lt 5 ] && [ "${ALWAYS_ABORT}" = "false" ]; then
echo "Attempting to restart KOReader . . ." >>crash.log 2>&1
echo "!!!!" >>crash.log 2>&1
fi
# Pause a bit if it's the first crash in a while, so that it actually has a chance of getting noticed ;).
if [ ${CRASH_COUNT} -eq 1 ]; then
if [ "${CRASH_COUNT}" -eq 1 ]; then
sleep 15
fi
# Cycle the last crash timestamp
@ -182,7 +182,7 @@ while [ "${RETURN_VALUE}" -ne 0 ]; do
# But if we've crashed more than 5 consecutive times, exit, because we wouldn't want to be stuck in a loop...
# NOTE: No need to check for ALWAYS_ABORT, CRASH_COUNT will always be 1 when it's true ;).
if [ ${CRASH_COUNT} -ge 5 ]; then
if [ "${CRASH_COUNT}" -ge 5 ]; then
echo "Too many consecutive crashes, aborting . . ." >>crash.log 2>&1
echo "!!!! ! !!!!" >>crash.log 2>&1
break

View File

@ -19,8 +19,8 @@ echo "$@" | nice -n 19 sh &
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)

View File

@ -8,14 +8,14 @@ case "${mime_type}" in
application/x*)
./"$1"
echo "Application done, hit enter to return"
read -r
read -r REPLY
exit
;;
text/x-shellscript*)
./"$1"
echo "Shellscript done, hit enter to return"
read -r
read -r REPLY
exit
;;
esac
@ -24,7 +24,7 @@ case "$1" in
*.sh)
sh "$1"
echo "Shellscript done, enter to return."
read -r
read -r REPLY
exit
;;