Why does GNU expr produce 0 for "expr a \> -aa"?

27 views Asked by At

Does any one know why

$ expr a \> -a

produce 1 and

$ expr a \> -aa

produce 0?

The version of coreutils:

$ pacman -Q coreutils                 
coreutils 9.4-2

It produce the same result when replace the - to + or *:

$ expr a \> +a
1
$ expr a \> +aa
0
$ expr a \> \*a
1
$ expr a \> \*aa
0

Why not treat the operator as an ordinary character?

Update: This is related to UTF-8 sorting:

$ LC_COLLATE=C expr a \> -a
1
$ LC_COLLATE=C expr a \> -aa
1
0

There are 0 answers