On 2025-02-17 15:13, Rupert Gallagher wrote:
~ $ echo -e "a1\na2" | sort
a1
a2
~ $ echo -e "a1\na2" | sort -h
a1
a2
Since A = B, the result of -u must be the same on both sets, by logic.
By that logic, since the output of these two commands:
echo -e 'a1\na2' | sort
echo -e 'a1\na2' | sort -n
are the same, then the result of -u be the same on both sets. But this
logic is wrong, in the sense that it disagrees with both longstanding
practice and with the POSIX.1-2024 standard
<https://pubs.opengroup.org/onlinepubs/9799919799/utilities/sort.html>,
which say that plain 'sort' uses the entire line as a key whereas 'sort
-n' uses a leading integer prefix (which in this example is empty so the
keys compare equal).
I get it that 'sort' doesn't behave the way you expected. But that's a
mismatch of expectations vs implementation, not a bug in the implementation.