mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Some more Kobo startup script tweaks (#6147)
* Simplify env siphoning some more * Nope, shellcheck, quoting this breaks it. (it preserves the LNs instead of abusing them as free field separators with word splitting). And, while this does break on env vars with spaces (since they'll be unquoted), that was already the case of the xargs approach. If we had read -d & printf %q, we could go with a pure shell approach, but we don't ;). * Document a working quoted variant. For science!
This commit is contained in:
@@ -100,8 +100,10 @@ if [ "${VIA_NICKEL}" = "true" ]; then
|
||||
# If we were spawned outside of Nickel, we'll need a few extra bits from its own env...
|
||||
if [ "${FROM_NICKEL}" = "false" ]; then
|
||||
# Siphon a few things from nickel's env (namely, stuff exported by rcS *after* on-animator.sh has been launched)...
|
||||
eval "$(xargs -n 1 -0 <"/proc/$(pidof -s nickel)/environ" | grep -s -F -e DBUS_SESSION_BUS_ADDRESS -e NICKEL_HOME -e WIFI_MODULE -e LANG -e WIFI_MODULE_PATH -e INTERFACE)"
|
||||
export DBUS_SESSION_BUS_ADDRESS NICKEL_HOME WIFI_MODULE LANG WIFI_MODULE_PATH INTERFACE
|
||||
# shellcheck disable=SC2046
|
||||
export $(grep -s -E -e '^(DBUS_SESSION_BUS_ADDRESS|NICKEL_HOME|WIFI_MODULE|LANG|WIFI_MODULE_PATH|INTERFACE)=' "/proc/$(pidof -s nickel)/environ")
|
||||
# NOTE: Quoted variant, w/ the busybox RS quirk (c.f., https://unix.stackexchange.com/a/125146):
|
||||
#eval "$(awk -v 'RS="\0"' '/^(DBUS_SESSION_BUS_ADDRESS|NICKEL_HOME|WIFI_MODULE|LANG|WIFI_MODULE_PATH|INTERFACE)=/{gsub("\047", "\047\\\047\047"); print "export \047" $0 "\047"}' "/proc/$(pidof -s nickel)/environ")"
|
||||
fi
|
||||
|
||||
# Flush disks, might help avoid trashing nickel's DB...
|
||||
@@ -120,8 +122,8 @@ fi
|
||||
|
||||
# check whether PLATFORM & PRODUCT have a value assigned by rcS
|
||||
if [ -z "${PRODUCT}" ]; then
|
||||
eval "$(xargs -n 1 -0 <"/proc/$(pidof -s udevd)/environ" | grep -s -F -e PRODUCT)"
|
||||
export PRODUCT
|
||||
# shellcheck disable=SC2046
|
||||
export $(grep -s -e '^PRODUCT=' "/proc/$(pidof -s udevd)/environ")
|
||||
fi
|
||||
|
||||
if [ -z "${PRODUCT}" ]; then
|
||||
@@ -131,8 +133,8 @@ fi
|
||||
|
||||
# PLATFORM is used in koreader for the path to the WiFi drivers (as well as when restarting nickel)
|
||||
if [ -z "${PLATFORM}" ]; then
|
||||
eval "$(xargs -n 1 -0 <"/proc/$(pidof -s udevd)/environ" | grep -s -F -e PLATFORM)"
|
||||
export PLATFORM
|
||||
# shellcheck disable=SC2046
|
||||
export $(grep -s -e '^PLATFORM=' "/proc/$(pidof -s udevd)/environ")
|
||||
fi
|
||||
|
||||
if [ -z "${PLATFORM}" ]; then
|
||||
|
||||
Reference in New Issue
Block a user