From 416c1c735603977095c123c845633435cba60a51 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sat, 20 Jun 2020 17:15:55 +0200 Subject: [PATCH] More robust way to detect our own path on Kobo (#6283) * More robust way to detect our own path on Kobo Should take care of all the weird and interesting ways people manage to find to break it... NOTE: "$(dirname $(realpath "${0}"))" works, too, but I'm not sure if really old devices ship with the realpath applet... * Abort early if KOREADER_DIR is null --- platform/kobo/koreader.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platform/kobo/koreader.sh b/platform/kobo/koreader.sh index 423217c7e..dea953577 100755 --- a/platform/kobo/koreader.sh +++ b/platform/kobo/koreader.sh @@ -1,11 +1,11 @@ #!/bin/sh export LC_ALL="en_US.UTF-8" -# working directory of koreader -KOREADER_DIR="${0%/*}" +# Compute our working directory in an extremely defensive manner +KOREADER_DIR="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)" -# we're always starting from our working directory -cd "${KOREADER_DIR}" || exit +# We rely on starting from our working directory, and it needs to be set, sane and absolute. +cd "${KOREADER_DIR:-/dev/null}" || exit # Attempt to switch to a sensible CPUFreq governor when that's not already the case... IFS= read -r current_cpufreq_gov <"/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"