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!
reviewable/pr6154/r1
NiLuJe 4 years ago committed by GitHub
parent 4d8cf983e2
commit e4d3b266ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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 we were spawned outside of Nickel, we'll need a few extra bits from its own env...
if [ "${FROM_NICKEL}" = "false" ]; then 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)... # 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)" # shellcheck disable=SC2046
export DBUS_SESSION_BUS_ADDRESS NICKEL_HOME WIFI_MODULE LANG WIFI_MODULE_PATH INTERFACE 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 fi
# Flush disks, might help avoid trashing nickel's DB... # Flush disks, might help avoid trashing nickel's DB...
@ -120,8 +122,8 @@ fi
# check whether PLATFORM & PRODUCT have a value assigned by rcS # check whether PLATFORM & PRODUCT have a value assigned by rcS
if [ -z "${PRODUCT}" ]; then if [ -z "${PRODUCT}" ]; then
eval "$(xargs -n 1 -0 <"/proc/$(pidof -s udevd)/environ" | grep -s -F -e PRODUCT)" # shellcheck disable=SC2046
export PRODUCT export $(grep -s -e '^PRODUCT=' "/proc/$(pidof -s udevd)/environ")
fi fi
if [ -z "${PRODUCT}" ]; then 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) # PLATFORM is used in koreader for the path to the WiFi drivers (as well as when restarting nickel)
if [ -z "${PLATFORM}" ]; then if [ -z "${PLATFORM}" ]; then
eval "$(xargs -n 1 -0 <"/proc/$(pidof -s udevd)/environ" | grep -s -F -e PLATFORM)" # shellcheck disable=SC2046
export PLATFORM export $(grep -s -e '^PLATFORM=' "/proc/$(pidof -s udevd)/environ")
fi fi
if [ -z "${PLATFORM}" ]; then if [ -z "${PLATFORM}" ]; then

Loading…
Cancel
Save