[yocto] busybox 1.21 ash bug?

Olof Johansson olof.johansson at axis.com
Tue Dec 10 07:53:26 PST 2013


Hi,

[Sorry for duplicate replies, apparently I wasn't subscribed
 with the right email address.]

On 13-12-10 13:22 +0100, Diego Sueiro wrote:
> Recently I switched to dora branch which builds busybox 1.21.
> I was using dylan branch with busybox 1.20 and the some shell
> scripts stopped working.  There is a problem related with "for"
> statements.
> 
> For example, on script below, it runs nice on busybox 1.20 but
> on 1.21 fails with the output: "./script.sh: line 3: syntax
> error: bad for loop variable".
> 
> #!/bin/sh
> 
> for (( i=1; i <= 5; i++ ))
> do
>  echo "Random number $i: $RANDOM"
> done

That type of for loop is a bashism; as far as I know and can
tell, busybox ash does not support it (even with ASH_BASH_COMPAT=y).

The code that is executed when the parser finds a "for" token:

ash.c: parse_command(void)
    ...
    switch (readtoken()) {
    ...
    case TFOR:
        if (readtoken() != TWORD || quoteflag || !goodname(wordtext))
            raise_error_syntax("bad for loop variable");

Are you sure it's using busybox ash when it actually works? I can
reproduce the error message your are seeing in both busybox 1.20
and 1.21.


RANDOM is also an extension, but one that is supported by busybox
(or rather, can be). The default defconfig in oe-core does not
enable it, see ASH_RANDOM_SUPPORT.

-- 
olofjn



More information about the yocto mailing list