[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bash is broken
From: |
Stephane Chazelas |
Subject: |
Re: Bash is broken |
Date: |
Sun, 13 May 2007 16:01:55 +0100 |
User-agent: |
Mutt/1.5.6i |
On Sun, May 13, 2007 at 08:19:13AM -0600, Eric Blake wrote:
[...]
> if [[ 1 > 2 ]]
>
> > This should be a string compare.
>
> Actually, when quoted properly, it should be a numeric comparison, not a
> string comparison.
[...]
It *is* a string comparison:
$ bash -c '[[ 02 > 1 ]]' || echo "02 is not greater than 1"
02 is not greater than 1
[[ a > b ]], [ a '>' b ] are string comparisons.
[ a -gt b ], [[ a -gt b ]], (( a > b )) are numeric comparisons.
expr's > is both depending on whether the operands are
recognised as integers or not.
in awk, it depends on the type of the arguments.
--
Stéphane