[oe] Use of == in shell scripts

Michael Smith msmith at cbnco.com
Tue Oct 26 16:21:39 UTC 2010


Andreas Oberritter wrote:
> On 10/26/2010 05:51 PM, Maupin, Chase wrote:

> I understand that bash is a requirement for now, but if possible, that
> should be changed. I don't think that root access to a machine should be
> necessary to build OE on Ubuntu (or maybe even on BSD flavors).

Well, maybe Ubuntu should be changed to use bash :)

>> If I remember correctly in bash "==" will also work with numbers whereas "=" is only for strings.
> 
> Both bash and dash on my system handle "[ "0" = 0 ]" or [ "0" = 1 ]
> correctly. Another operator "-eq" exists, which is only for numbers.

 From what I can see, it looks like = and == are equivalent in bash, so 
we should use = so we're not tied to bash.

-eq is for numeric comparison. For example, [ 01 -eq 1 ] but not
[ "01" = "1" ].

Mike




More information about the Openembedded-devel mailing list