Skip to content

Missing du human readable locale support (french) breaks sorting #11956

@anisse

Description

@anisse

When using du with -h, the locale is not taken into account by du; this breaks sorting with -h which does take into account the locale.
Reproducer:

#!/bin/bash
sort --version
du --version
echo $LANG
cd $(mktemp -d sizeXXXXX)
dd if=/dev/zero bs=1k count=1300 of=big 2> /dev/null
dd if=/dev/zero bs=1k count=500 of=small 2> /dev/null
du -axh | sort -h
rm big small

With uutils:

> ./reproducer.sh
sort (uutils coreutils) 0.8.0
du (uutils coreutils) 0.8.0
fr_FR.UTF-8
1.3M	./big
1.8M	.
500K	./small
> env LANG=C ./reproducer.sh
sort (uutils coreutils) 0.8.0
du (uutils coreutils) 0.8.0
C
500K	./small
1.3M	./big
1.8M	.

With coreutils 9.1 (sorry for the old version, I don't expect a change with a more recent one):

> ./reproducer.sh 
sort (GNU coreutils) 9.1
[cut]
fr_FR.UTF-8
500K	./small
1,3M	./big
1,8M	.
> env LANG=C ./reproducer.sh
sort (GNU coreutils) 9.1
[cut]
C
500K	./small
1.3M	./big
1.8M	.

A potential workaround is to use du -h | env LANG=C sort -h ; but this gets quite annoying.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions