On 09/26/2011 10:22 PM, Dave Reisner wrote:
If we encounter a BOOT_IMAGE var taken from grub2, the first character
could be a '(' which will throw off busybox's parser and error out.
Reverse the comparison so that the LHS is always a constant, which can
be compared to anything (including nothing at all).

Fixes FS#26119.

Signed-off-by: Dave Reisner<dreis...@archlinux.org>
---
  init_functions |    6 +++---
  1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/init_functions b/init_functions
index fe29961..edaf87c 100644
--- a/init_functions
+++ b/init_functions
@@ -45,8 +45,8 @@ parse_cmdline() {
                  # only export stuff that does work with ash :)
                  *=*) rhs="$(echo "${w}" | cut -d= -f2-)"
                      lhs="$(echo "${w}" | cut -d= -f1 | sed 
's|\.|_|g;s|-|_|g;')"
-                    if [ "${rhs:0:1}" = "\"" ]; then
-                        if [ "${rhs:$((${#rhs}-1))}" = "\"" ]; then
+                    if [ "\"" = "${rhs:0:1}" = ]; then
+                        if [ "\"" = "${rhs:$((${#rhs}-1))}" ]; then
                              rhs="${rhs:1:$((${#rhs}-2))}"
                          else
                              rhs="${rhs:1}"
@@ -61,7 +61,7 @@ parse_cmdline() {
                      ;;
              esac
          else
-            if [ "${w:$((${#w}-1))}" = "\"" ]; then
+            if [ "\"" = "${w:$((${#w}-1))}" ]; then
                  rhs="${rhs} ${w:0:$((${#w}-1))}"
                  in_quotes=0
                  (echo "${lhs}" | grep -qe '^[0-9]' -e '[^a-zA-Z0-9_]') || 
eval ${lhs}=\${rhs}

I testing the whole branch with archiso. But this patch introduced a regression:

"ash: =: unknown operand"
:: Starting udevd...

tracing shows:

+ echo archisobasedir=arch
+ lhs=archisobasedir
+ [ " = a = ]
ash: =: unknown operand


+ echo archisolabel=ARCH_201109
+ lhs=archisolabel
+ [ " = A = ]
ash: =: unknown operand

+ echo initrd=/arch/boot/i686/archiso.img
+ lhs=initrd
+ [ " = / = ]
ash: =: unknown operand

etc

--
Gerardo Exequiel Pozzi
\cos^2\alpha + \sin^2\alpha = 1

Reply via email to