aboutsummaryrefslogtreecommitdiff
path: root/init
diff options
context:
space:
mode:
Diffstat (limited to 'init')
-rwxr-xr-xinit24
1 files changed, 21 insertions, 3 deletions
diff --git a/init b/init
index af507c0..0eed64d 100755
--- a/init
+++ b/init
@@ -104,6 +104,11 @@ sensors-detect --auto
# foo='foo fox'
# bar="bar 'box'"
#
+# Or (as rewritten by GRUB):
+#
+# 'foo=foo fox'
+# "bar=bar 'box'"
+#
# First we separete quoted variables and arguments with newlines (giving
# priority to assignments). Then we replace whitespaces with newline on
# lines that don't contain quotes. Finally, clean up by removing blank
@@ -120,11 +125,24 @@ readarray -t cmdline < <(cat /proc/cmdline | \
#
info "command line:"
for v in "${cmdline[@]}"; do
- var="$(sed -n -re 's/^buildos\.([^=]+)=.*$/\1/p' <<<"$v")" # Extract name.
+
+ # Rewrite "x=y" as x="y" (as well as the single-quote variant).
+ #
+ v1="$(sed -n -re "s/^\"([^= ]+)=(.*)\"\$/\1=\"\2\"/p" <<<"$v")"
+ if [ -n "$v1" ]; then
+ v="$v1"
+ else
+ v1="$(sed -n -re "s/^'([^= ]+)=(.*)'\$/\1='\2'/p" <<<"$v")"
+ if [ -n "$v1" ]; then
+ v="$v1"
+ fi
+ fi
+
+ var="$(sed -n -re 's/^buildos\.([^= ]+)=.*$/\1/p' <<<"$v")" # Extract name.
if [ -n "$var" ]; then
- val="$(sed -re 's/^[^=]+=(.*)$/\1/' <<<"$v")" # Extract value.
- val="$(sed -re "s/^('(.*)'|\"(.*)\")$/\2\3/" <<<"$val")" # Strip quoted.
+ val="$(sed -re 's/^[^= ]+=(.*)$/\1/' <<<"$v")" # Extract value.
+ val="$(sed -re "s/^('(.*)'|\"(.*)\")\$/\2\3/" <<<"$val")" # Strip quoted.
info " $var=$val"
# If the variable contains a dot, then it is a toolchain variable and we