aboutsummaryrefslogtreecommitdiff
path: root/buildos
diff options
context:
space:
mode:
Diffstat (limited to 'buildos')
-rwxr-xr-xbuildos24
1 files changed, 21 insertions, 3 deletions
diff --git a/buildos b/buildos
index 6b81de3..6a7bcfb 100755
--- a/buildos
+++ b/buildos
@@ -59,6 +59,11 @@ info "starting build os monitor..."
# 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 quites. Finally, we clean up by removing blank
@@ -81,11 +86,24 @@ declare -A toolchains
toolchains["default"]=""
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.
# Recognize some variables as arrays.
#