[PATCH] More ash test conditions.

Mike Frysinger vapier at gentoo.org
Tue Apr 8 14:49:16 PDT 2008


On Tuesday 08 April 2008, James Simmons wrote:
> > > Index: shell/ash.c
> > > ===================================================================
> > > --- shell/ash.c	(revision 21673)
> > > +++ shell/ash.c	(working copy)
> > > @@ -12878,12 +12878,21 @@
> > >
> > >  /* longest must be first */
> > >  static const char op_tokens[] ALIGN1 = {
> > > +	'-','e','q',0, TOK_EQ,
> > > +	'-','n','e',0, TOK_NE,
> > > +	'-','l','t',0, TOK_LT,
> > > +	'-','g','t',0, TOK_GT,
> > > +	'-','g','e',0, TOK_GE,
> > > +	'-','l','t',0, TOK_LT,
> > > +	'-','l','e',0, TOK_LE,
> > >  	'<','<','=',0, TOK_LSHIFT_ASSIGN,
> > >  	'>','>','=',0, TOK_RSHIFT_ASSIGN,
> > >  	'<','<',    0, TOK_LSHIFT,
> > >  	'>','>',    0, TOK_RSHIFT,
> > >  	'|','|',    0, TOK_OR,
> > > +	'-','o',    0, TOK_OR,
> > >  	'&','&',    0, TOK_AND,
> > > +	'-','a',    0, TOK_AND,
> > >  	'!','=',    0, TOK_NE,
> > >  	'<','=',    0, TOK_LE,
> > >  	'>','=',    0, TOK_GE,
> >
> > Can you give examples of changed behavior?
>
> Actually testing the patch now something changed from busybox 1.6.1. It no
> longer works. The problem was this. Now I don't know if this is a bashism?
>
> #!/bin/sh
>
> len=10
> i=0
>
> while [[ $((++i)) -lt len ]]; do
>         echo "i = $i"
> done

the [[...]] is a bashism.  in this case you can just change it to [...].  in 
this particular case, [...] will behave exactly the same as bash's [[...]].  
the ++ operator is optional POSIX extension.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: This is a digitally signed message part.
Url : http://busybox.net/lists/busybox/attachments/20080408/d9abd6d1/attachment.pgp 


More information about the busybox mailing list