barebox extending boot-scripts

Sascha Hauer sha at pengutronix.de
Mon Jan 31 03:03:15 PST 2022


Hi Frank,

On Sat, Jan 29, 2022 at 11:40:08AM +0100, Frank Wunderlich wrote:
> Hi,
> > Gesendet: Donnerstag, 06. Januar 2022 um 09:08 Uhr
> > Von: "Sascha Hauer" <sha at pengutronix.de>
> 
> > It works for example with:
> >
> > for i in /mnt/sd.1/extlinux/Image*; do basename $i b; echo $b; done
> 
> this works with full path, but not if using a var for dir var
> 
> barebox at BPI R2PRO:/ i=0;for f in /mnt/sd.1/extlinux/Image*; do basename $f b; echo "$i:$b";let i++; done
> 0:Image_5.16
> 1:Image_5.16-next.gz
> 2:Image_5.16.gz
> 3:Image_5.16.gz.bak
> 4:Image_5.16_q64
> 5:Image_bpi
> barebox at BPI R2PRO:/ imgdir=/mnt/sd.1/extlinux/
> barebox at BPI R2PRO:/ i=0;for f in $imgdir/Image*; do basename $f b; echo "$i:$b";let i++; done

You've hit yet another hush bug. Normally when you do a

# foo="bar baz"
# for i in $foo; echo $i; done
bar
baz

$foo expands to two words. This works as expected.

This also works with:

# for i in *; do echo $i; done
dev
env
foo
mnt
tmp

Using a combination of glob pattern and variable however does not work:

# foo="*"
# for i in $foo; do echo $i; done
dev env foo mnt tmp

hush inserts the expanded glob pattern of "*" as a single word into the
parsing data, so i doesn't contain the separated words, but instead "dev
env foo mnt tmp" at once.

There are many bugs like this in hush and we've fixed several of them,
possibly inserting other bugs along the way. I've starred on the code
for a long time over the years and still don't fully understand it. When
changing things I'm often not sure about its implications. To put it
shortly: hush is broken beyond repair.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list