bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

handling of ints/longs


From: roberto@
Subject: handling of ints/longs
Date: Wed, 10 Jul 2002 18:53:02 -0400 (EDT)

Hi.

I just upgraded to RedHat 7.3 on a test machine and am playing with it
before deploying the new image to our labs.  We have a bunch of things
that depend on timestamp files, the contents of which are generated by
something like:

/bin/date +%Y%m%d%H%M%S

If I issue that command right now I get:

20020710183600

Which is obviously much bigger than a signed long (sizeof(long) is 4)

On the old RedHat 6.2 machines (GNU bash, version 1.14.7(1)) our scripts
work.  On the new RedHat 7.3 machine, they fail.  I realize it has to do
with the big numbers being truncated and that it's likely that you "fixed"
bash to conform to what it says on the man pages, but we have a lot of
these scripts that still run under Solaris and IRIX and finding and
changing them is going to be a nuisance.  Is there anything I can do to
change the behaviour of bash back to what it was (we actually invoke it as
/bin/sh)?  I'm assuming that this is not a bug but a feature.

        thanks
        bob


---------------------------------------------------------------------
Roberto Mansoni                                   Phone (416)978-5898
Systems Administrator, ECF                        Fax   (416)978-7320
University of Toronto                  email  address@hidden
Toronto, Canada M5S 1A4                   or  address@hidden

"It is preferable not to travel with a dead man."   --- Henri Michaux

--------------------------------------------

p3.ecf% cat stamp1 stamp2
20020710142335
20020710142344
p3.ecf% cat stamptest
#!/bin/sh
let first=`/bin/cat ./stamp1`
let second=`/bin/cat ./stamp2`

echo stamp1 is $first
echo stamp2 is $second

if [ $first > $second ]; then
        echo $first is greater than $second
fi
if [ $first < $second ]; then
        echo $first is less than $second
fi

---------------------------------------------------

p3.ecf% bash -version
GNU bash, version 2.05a.0(1)-release (i686-pc-linux-gnu)
Copyright 2001 Free Software Foundation, Inc.
p3.ecf% ./stamptest2
stamp1 is 20020710142335
stamp2 is 20020710142344
./stamptest2: [: 20020710142335: integer expression expected
./stamptest2: [: 20020710142335: integer expression expected

---------------------------------------------------

p6.ecf% bash -version
GNU bash, version 1.14.7(1)
bash$ exit
p6.ecf% ./stamptest2
stamp1 is 20020710142335
stamp2 is 20020710142344
20020710142335 is less than 20020710142344





reply via email to

[Prev in Thread] Current Thread [Next in Thread]