[hackers] [PATCH][sbase] sort: Don't do top-level sort when -c is used with -k

From: Richard Ipsum <richardipsum_AT_vx21.xyz>
Date: Wed, 1 Jan 2020 11:51:06 +0000

---
 sort.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/sort.c b/sort.c
index fc76738..c586394 100644
--- a/sort.c
+++ b/sort.c
_AT_@ -383,10 +383,15 @@ main(int argc, char *argv[])
 		usage();
 	} ARGEND
 
-	/* -b shall only apply to custom key definitions */
-	if (TAILQ_EMPTY(&kdhead) && global_flags)
-		addkeydef("1", global_flags & ~(MOD_STARTB | MOD_ENDB));
-	addkeydef("1", global_flags & MOD_R);
+	if (TAILQ_EMPTY(&kdhead)) {
+		if (global_flags) {
+			/* -b shall only apply to custom key definitions */
+			addkeydef("1", global_flags & ~(MOD_STARTB | MOD_ENDB));
+		}
+		addkeydef("1", global_flags & MOD_R);
+	} else if (!Cflag && !cflag) {
+		addkeydef("1", global_flags & MOD_R);
+	}
 
 	if (!argc) {
 		if (Cflag || cflag) {
-- 
2.24.1
Received on Wed Jan 01 2020 - 12:51:06 CET

This archive was generated by hypermail 2.3.0 : Wed Jan 01 2020 - 13:00:22 CET