On 1 October 2012 18:36, Michal Hlavinka <mhlav...@redhat.com> wrote: > Hi, > > one our user complains about string comparison result: > > var1="4000" > var2=" 500" > [[ $var2 > $var1 ]]; echo $? > 0 > [[ "$var2" > "$var1" ]]; echo $? > 0 > > > Based on ksh man page: > string1 < string2 > True, if string1 comes before string2 based on ASCII value of their > characters. > > Space is ASCII 32, '4' is ASCII 52, thus space is less than 4. So, as per > ASCII value comparison, "4000" should have been greater than " 500", whereas > result is shows " 500" is greater. > > Odd is that old bash gave "correct" result, but the new one gives the > "wrong" one - the same as ksh, so I wonder if I miss something.
I think ASCII is the wrong term here - it's dependent on the collating and character sort order of the locale - it has to be so it works in multibyte locales. Lionel _______________________________________________ ast-developers mailing list ast-developers@research.att.com https://mailman.research.att.com/mailman/listinfo/ast-developers