diff --git a/kodev b/kodev index 598a92e35..ce665a627 100755 --- a/kodev +++ b/kodev @@ -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 } diff --git a/platform/cervantes/disable-usbms.sh b/platform/cervantes/disable-usbms.sh index f9768b0e2..3c59d91f7 100644 --- a/platform/cervantes/disable-usbms.sh +++ b/platform/cervantes/disable-usbms.sh @@ -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 - diff --git a/platform/cervantes/resume.sh b/platform/cervantes/resume.sh index e689b8bf5..0d01a2220 100755 --- a/platform/cervantes/resume.sh +++ b/platform/cervantes/resume.sh @@ -1,4 +1,3 @@ #! /bin/sh echo 0 >/sys/power/state-extended - diff --git a/platform/cervantes/suspend.sh b/platform/cervantes/suspend.sh index 5b19fa722..0b935b72b 100755 --- a/platform/cervantes/suspend.sh +++ b/platform/cervantes/suspend.sh @@ -12,4 +12,3 @@ sync # Suspend to RAM. echo mem >/sys/power/state - diff --git a/platform/linux/koreader.sh b/platform/linux/koreader.sh index 9d4f1cb4c..c2b9a1e5f 100755 --- a/platform/linux/koreader.sh +++ b/platform/linux/koreader.sh @@ -28,4 +28,3 @@ done export -n KO_MULTIUSER exit ${RETURN_VALUE} - diff --git a/platform/pocketbook/koreader.app b/platform/pocketbook/koreader.app index 6a79f1574..18ef49e74 100755 --- a/platform/pocketbook/koreader.app +++ b/platform/pocketbook/koreader.app @@ -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 diff --git a/plugins/backgroundrunner.koplugin/wrapper.sh b/plugins/backgroundrunner.koplugin/wrapper.sh index 8415f972f..1799196cb 100755 --- a/plugins/backgroundrunner.koplugin/wrapper.sh +++ b/plugins/backgroundrunner.koplugin/wrapper.sh @@ -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) diff --git a/plugins/terminal.koplugin/shfm_opener.sh b/plugins/terminal.koplugin/shfm_opener.sh index 8811dd16d..5634fb9ee 100755 --- a/plugins/terminal.koplugin/shfm_opener.sh +++ b/plugins/terminal.koplugin/shfm_opener.sh @@ -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 ;;