[coreboot] bash math

Jordan Crouse jordan.crouse at amd.com
Tue Sep 30 16:27:59 CEST 2008


On 30/09/08 05:19 +0200, Peter Stuge wrote:
> Jordan Crouse wrote:
> > > It works unless the vga bios file is zero bytes long :)
> > 
> > Fixed - turns out that expr has a trick up its sleeve:
> > Exit status is 0 if EXPRESSION is neither null nor 0, 1  if
> > EXPRESSION is  null  or  0,  2 if EXPRESSION is syntactically
> > invalid, and 3 if an error occurred
> 
> I like result=$[$[${something}]+$[${other}]] to not have to care.
> 
> $[] evaluates to 0
> $[notanumber] also evaluates to 0

Not everybody is using bash, Peter.  I would prefer to use bash too,
but we have to cater to the lowest common denominator, which is /bin/sh.
Thus, expr.

Jordan


-- 
Jordan Crouse
Systems Software Development Engineer 
Advanced Micro Devices, Inc.





More information about the coreboot mailing list