summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coreutils/sort.c9
-rwxr-xr-xtestsuite/sort.tests10
2 files changed, 15 insertions, 4 deletions
diff --git a/coreutils/sort.c b/coreutils/sort.c
index 80b578fc2..01b7c44e5 100644
--- a/coreutils/sort.c
+++ b/coreutils/sort.c
@@ -652,11 +652,12 @@ int sort_main(int argc UNUSED_PARAM, char **argv)
/* Handle -u */
if (option_mask32 & FLAG_u) {
int j = 0;
- /* coreutils 6.3 drop lines for which only key is the same
- * -- disabling last-resort compare, or else compare_keys()
- * will be the same only for completely identical lines.
+ /* coreutils 6.3 drop lines for which only key is the same:
+ * - disabling last-resort compare, or else compare_keys()
+ * will be the same only for completely identical lines
+ * - disabling -s (same reasons)
*/
- option_mask32 |= FLAG_no_tie_break;
+ option_mask32 = (option_mask32 | FLAG_no_tie_break) & (~FLAG_s);
for (i = 1; i < linecount; i++) {
if (compare_keys(&lines[j], &lines[i]) == 0)
free(lines[i]);
diff --git a/testsuite/sort.tests b/testsuite/sort.tests
index fb2cc91bd..8dbadbdae 100755
--- a/testsuite/sort.tests
+++ b/testsuite/sort.tests
@@ -230,4 +230,14 @@ testing "sort -k2,2M" \
3 March
" ""
+testing "sort -s -u" \
+"sort -s -u -k 2 input" "\
+z a
+z b
+" "\
+z b
+a b
+z a
+a a" ""
+
exit $FAILCOUNT