Skip to contentSkip to conversation

what's with the loop with "in in" in u-boot.inc?

DISCUSSION Robert P. J. Day 3 participants 4 messages Mar 7, 2015 – Mar 8, 2015

lore
Share & tools
lore
#0 lore raw

based on a recent post to this(?) list, i was curious about the
following loop construct in u-boot.inc:

        for config in ${UBOOT_MACHINE}; do
            for type in in ${UBOOT_CONFIG}; do
                if [ "${type}"x = "in"x ]
                then
                    continue
                fi

the words "in in" above don't appear to be a typo, as the next
condition explicitly checks for the value "in" and skips it. what's the rationale for that? i used "git blame" to examine the commit that introduced that, but it says nothing about that curiosity.

rday

Signature · 7 lines
========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================
#1 lore raw
Quoted 11 lines · Robert P. J. Day

based on a recent post to this(?) list, i was curious about the
following loop construct in u-boot.inc:

       for config in ${UBOOT_MACHINE}; do
           for type in in ${UBOOT_CONFIG}; do
               if [ "${type}"x = "in"x ]
               then
                   continue
               fi
Quoted 3 lines

the words "in in" above don't appear to be a typo, as the next
condition explicitly checks for the value "in" and skips it. what's the rationale for that? i used "git blame" to examine the commit that

for may barf on empty iteration input.
One usually uses for i in ${foo} '';
and skips i with zero length. Any other is obviously fine, too though so nothing wrong or odd here.

HTH,

Quoted 3 lines

introduced that, but it says nothing about that curiosity.

rday

#2 lore raw
Quoted 12 lines · Bernhard Reutner-Fischer
Quoted 11 lines · Robert P. J. Day

based on a recent post to this(?) list, i was curious about the
following loop construct in u-boot.inc:

        for config in ${UBOOT_MACHINE}; do
            for type in in ${UBOOT_CONFIG}; do
                if [ "${type}"x = "in"x ]
                then
                    continue
                fi
Quoted 7 lines
Quoted 3 lines

the words "in in" above don't appear to be a typo, as the next
condition explicitly checks for the value "in" and skips it. what's the rationale for that? i used "git blame" to examine the commit that

for may barf on empty iteration input.
One usually uses for i in ${foo} '';
and skips i with zero length. Any other is obviously fine, too though so nothing wrong or odd here.

But this code is only executed if ${UBOOT_CONFIG} is non-empty so this test is nonsense.

My guess is that the code originally tested for ${UBOOT_CONFIG} being empty this way, then the if/then/else was added (look at the indentation) and the original test was never removed (which does no harm)

Quoted 8 lines

HTH,

Quoted 3 lines

introduced that, but it says nothing about that curiosity.

rday

Signature · 4 lines
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------
#3 lore raw
Quoted 23 lines · Gary Thomas
Quoted 13 lines · Bernhard Reutner-Fischer
Quoted 11 lines · Robert P. J. Day

based on a recent post to this(?) list, i was curious about the
following loop construct in u-boot.inc:

        for config in ${UBOOT_MACHINE}; do
            for type in in ${UBOOT_CONFIG}; do
                if [ "${type}"x = "in"x ]
                then
                    continue
                fi
Quoted 8 lines
Quoted 3 lines

the words "in in" above don't appear to be a typo, as the next
condition explicitly checks for the value "in" and skips it. what's the rationale for that? i used "git blame" to examine the commit that

for may barf on empty iteration input.
One usually uses for i in ${foo} '';
and skips i with zero length. Any other is obviously fine, too though so nothing wrong or odd here.

Quoted 7 lines

But this code is only executed if ${UBOOT_CONFIG} is non-empty so this test is nonsense.

My guess is that the code originally tested for ${UBOOT_CONFIG} being empty this way, then the if/then/else was added (look at the indentation) and the original test was never removed (which does no harm)

technically, it *is* possible that UBOOT_CONFIG contains a non-empty
string of spaces so, yes, that test still has some technical value but ... you know ... yuck. movin' on ...

rday

Signature · 7 lines
========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================