Dear Rasmus,

In message <20200216152427.e80c7240...@gemini.denx.de> I wrote:
>
> So lets change my little script to add setting "left":
>
>       slot=none
>       for i in $BOOT_ORDER ; do
>       setenv tmp_cmd 'setexpr tmp_val sub '^' "" $'BOOT_${i}_LEFT
>       run tmp_cmd
>       test $slot = none && test $tmp_val -gt 0 && slot=$i && left=$tmp_val
>       done
>       echo "## Chosen Slot = $slot ; Left = $left"
>
> Result:
>
>       ## Chosen Slot = C ; Left = 2

Actually I'm stupid.  It's much easier this way, and without the
ugly printed messages:

        setenv BOOT_ORDER A B C D
        setenv BOOT_A_LEFT 0
        setenv BOOT_B_LEFT 0
        setenv BOOT_C_LEFT 2
        setenv BOOT_D_LEFT 5

        slot=none
        for i in $BOOT_ORDER ; do
        setenv tmp_cmd 'setenv tmp_val $'BOOT_${i}_LEFT
        run tmp_cmd
        test $slot = none && test $tmp_val -gt 0 && slot=$i && left=$tmp_val
        done
        echo "## Chosen Slot = $slot ; Left = $left"

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
A modem is a baudy house.

Reply via email to