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.

Michal
_______________________________________________
ast-developers mailing list
ast-developers@research.att.com
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to