bug in ksh?

Andrzej Krzysztofowicz ankry at green.mif.pg.gda.pl
Fri Jul 7 20:31:24 CEST 2006


Jakub Bogusz wrote:
> On Fri, Jul 07, 2006 at 06:24:50PM +0200, Andrzej 'The Undefined' Dopierała wrote:
> > On Fri, Jul 07, 2006 at 11:54:33AM +0100, wrobell wrote:
> > > > weirdy difference between sh from ksh and bash:
> > > > 
> > > > [undefine at omega ~]$ bash
> > > > [undefine at omega ~]$ [ "3000000000" -ge "2000000000" ] && echo works
> > > > works
> > > > [undefine at omega ~]$ sh
> > > > [undefine at omega ~]$ [ "3000000000" -ge "2000000000" ] && echo works
> > > > [undefine at omega ~]$ 
> > > > 
> > > > [undefine at omega ~]$ rpm -qf /bin/sh /bin/bash                                                                                             
> > > > pdksh-5.2.14-43
> > > > bash-3.1.017-1
> > > 
> > > 32 bit unsigned int vs 32 bit signed int vs 64 bit long?
> > ano.
> > but - it works differrent on miscelious archs (on 64bits - works ok).
> > 
> > what is correct? bash or ksh behaviour?
> 
> I think bash is correct. But ksh may be correct too - see below.
> 
> > i think ksh behaviour is a bug...
> 
> Does POSIX/SUS specify what integer values should be supported?
> I can't find it now.
> 
> I assume that values larger than some value are allowed to give
> "undefined" results.

I think it is OK unless 64-bit arithmetic is explicitely required.
Older bash versions (see Ra) has the same behaviour AFAIR.

If a script needs 64-bit arithmetics, it should check whether it is
supported.

-- 
=======================================================================
  Andrzej M. Krzysztofowicz                  ankry at mif.pg.gda.pl
  phone (48)(58) 347 14 61
Faculty of Applied Phys. & Math.,   Gdansk University of Technology


More information about the pld-devel-en mailing list