Bug 1355780

Summary: sort doesn't work with locales where thousands_sep is space in human readable mode
Product: Red Hat Enterprise Linux 7 Reporter: Jakub Prokes <jprokes>
Component: coreutilsAssignee: Kamil Dudka <kdudka>
Status: CLOSED NEXTRELEASE QA Contact: qe-baseos-daemons
Severity: low Docs Contact:
Priority: unspecified    
Version: 7.3CC: kdudka
Target Milestone: rcKeywords: Patch
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-01-21 12:05:31 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jakub Prokes 2016-07-12 14:10:38 UTC
Description of problem:
Locales like unm_US.utf8 where is thousands_sep space caused sort -h working improperly. In these case sorting works only on last column because spaces in between columns are accepted as thousands separator.


Version-Release number of selected component (if applicable):
coreutils-8.22-18.el7.x86_64

How reproducible:
LC_ALL=sv_SE.utf8 sort -k1h data-comma.txt

Actual results:
1k      1,2G    1k
1,2k    1G      1,2k
1M      1,2M    1M
1,2M    1M      1,2M
1G      1,2k    1G
1,2G    1k      1,2G
1T      1T      1T
1,2T    1       1,2T
1       1,2T    1


Expected results:
1       1,2T    1
1k      1,2G    1k
1,2k    1G      1,2k
1M      1,2M    1M
1,2M    1M      1,2M
1G      1,2k    1G
1,2G    1k      1,2G
1T      1T      1T
1,2T    1       1,2T


Additional info:
$ cat data-comma.txt
1       1,2T    1
1k      1,2G    1k
1M      1,2M    1M
1G      1,2k    1G
1T      1T      1T
1,2k    1G      1,2k
1,2M    1M      1,2M
1,2G    1k      1,2G
1,2T    1       1,2T

$ LC_ALL=sv_SE.utf8 locale -k LC_NUMERIC
decimal_point=","
thousands_sep=" "
grouping=3;3
numeric-decimal-point-wc=44
numeric-thousands-sep-wc=32
numeric-codeset="UTF-8"

Comment 1 Kamil Dudka 2016-07-12 14:38:59 UTC
This bug is unrelated to our i18n patch.  The same happens with upstream sort.

Comment 2 Kamil Dudka 2016-07-17 16:06:40 UTC
I have proposed a fix upstream:

http://debbugs.gnu.org/cgi/bugreport.cgi?bug=24015

Comment 4 Kamil Dudka 2016-07-19 13:22:06 UTC
fixed in coreutils-8.25-14.fc25:

http://pkgs.fedoraproject.org/cgit/rpms/coreutils.git/commit/?id=8b01f237

Comment 5 Fedora Update System 2016-10-31 17:46:14 UTC
coreutils-8.25-7.fc24 has been submitted as an update to Fedora 24. https://bodhi.fedoraproject.org/updates/FEDORA-2016-75adc7da4f

Comment 6 Fedora Update System 2016-11-01 18:22:52 UTC
coreutils-8.25-7.fc24 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-75adc7da4f

Comment 7 Jakub Prokes 2016-11-14 10:01:30 UTC
I can confirm fix on fc24.

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: [   LOG    ] :: Setup
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [   PASS   ] :: Checking for the presence of coreutils rpm 
:: [   LOG    ] :: Package versions:
:: [   LOG    ] ::   coreutils-8.25-7.fc24.x86_64
:: [   LOG    ] :: Duration: 0s
:: [   LOG    ] :: Assertions: 1 good, 0 bad
:: [   PASS   ] :: RESULT: Setup


::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: [   LOG    ] :: Test
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [   LOG    ] :: Detected decimal mark ',' for locale sv_SE.utf8
:: [   PASS   ] :: Decimal point have to be known. (Expected 0, got 0)
:: [   PASS   ] :: LC_ALL=sv_SE.utf8 sort -k1h (Expected 0, got 0)
:: [   PASS   ] :: LC_ALL=sv_SE.utf8 sort -k2h (Expected 0, got 0)
:: [   PASS   ] :: LC_ALL=sv_SE.utf8 sort -k3h (Expected 0, got 0)

Comment 12 Kamil Dudka 2019-01-21 12:05:31 UTC
Fixing this in RHEL-7 is risky because it introduces a change in behavior.  There is no customer case behind this bug.  Closing NEXTRELEASE as it is fixed in RHEL-8.