cc: ast-developers@research.att.com
Subject: Re: [ast-developers] string <> comparison in [[ ]]
--------

> 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
> 

I get 1 and 1 when I run this.

$ uname -a
Linux terra.research.att.com 2.6.32-279.1.1.el6.x86_64 #1 SMP Tue Jul 10 
13:47:21 UTC 2012 x86_64 x86_64 i386-64 GNU/Linux
$ print $LC_ALL
C

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

Reply via email to