bash: Conditional expressions < and > do not perform as documented.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Gnu Bash |
Confirmed
|
Undecided
|
Unassigned | ||
bash (Ubuntu) |
Triaged
|
Medium
|
Unassigned |
Bug Description
Binary package hint: bash
In the bash documentation, the conditional expression string1 > string2 is said to be true if string1 sorts after string2 lexicographically according to the current locale. However (example from 8.04):
bshotts@twin2:~$ lsb_release -rd
Description: Ubuntu 8.04.2
Release: 8.04
bshotts@twin2:~$ apt-cache policy bash
bash:
Installed: 3.2-0ubuntu18
Candidate: 3.2-0ubuntu18
Version table:
*** 3.2-0ubuntu18 0
500 http://
100 /var/lib/
3.2-0ubuntu16 0
500 http://
bshotts@twin2:~$ locale
LANG=en_US.UTF-8
LC_CTYPE=
LC_NUMERIC=
LC_TIME=
LC_COLLATE=
LC_MONETARY=
LC_MESSAGES=
LC_PAPER=
LC_NAME=
LC_ADDRESS=
LC_TELEPHONE=
LC_MEASUREMENT=
LC_IDENTIFICATI
LC_ALL=
bshotts@twin2:~$ [ 'b' \> 'a' ] && echo true # works
true
bshotts@twin2:~$ [ 'b' \> 'A' ] && echo true # works
true
bshotts@twin2:~$ [ 'B' \> 'a' ] && echo true # does not work, should be true
bshotts@twin2:~$ [ 'B' \> 'A' ] && echo true #works
true
bshotts@twin2:~$ [ 'Z' \> 'a' ] && echo true # does not work, should be true
bshotts@twin2:~$
The results of the third and fifth cases ( 'B' \> 'a' and 'Z' \> 'a' ) suggest that POSIX collation order is being used rather than the collation order for the current locale.
Indeed - the implementation uses strcmp() rather than strcoll().