From 5ebd387640ed45bd320431ad30ec92103166ef74 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Wed, 19 Dec 2018 16:50:10 -0600 Subject: Fix sort -x attached to a key. --- tests/sort.test | 4 +--- toys/posix/sort.c | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/sort.test b/tests/sort.test index 619bbd02..2070d10c 100755 --- a/tests/sort.test +++ b/tests/sort.test @@ -92,9 +92,9 @@ testing "-x" "sort -x" "010\na0\n 0c0\n" "" "a0\n010\n 0c0\n" testing "" "sort -k2,2f" "A b b\na B C\na B a\n" "" "a B a\nA b b\na B C\n" testing "" "sort -k2,2" "a B C\na B a\nA b b\n" "" "a B a\nA b b\na B C\n" testing "" "sort -f -k2,2" "A b b\na B C\na B a\n" "" "a B a\nA b b\na B C\n" - testing "" "sort -t, -k3n" "3,4,1,2\n4,1,2,3\n1,2,3,4\n2,3,4,1\n" "" \ "1,2,3,4\n2,3,4,1\n4,1,2,3\n3,4,1,2\n" +testing "-kx" "sort -k1,1x" "3\na\n0c\n" "" "0c\na\n3\n" optional SORT_FLOAT @@ -102,5 +102,3 @@ optional SORT_FLOAT testing "-g" "sort -g" \ "bork\nNaN\n-inf\n0.4\n1.222\n01.37\n2.1\n+infinity\n" "" \ "01.37\n1.222\n2.1\n0.4\nNaN\nbork\n-inf\n+infinity\n" - - diff --git a/toys/posix/sort.c b/toys/posix/sort.c index 2f4d49a0..4c9452eb 100644 --- a/toys/posix/sort.c +++ b/toys/posix/sort.c @@ -328,7 +328,7 @@ void sort_main(void) // Was it a flag that can apply to a key? - if (!temp2 || flag>FLAG_b + if (!temp2 || flag>FLAG_x || (flag&(FLAG_u|FLAG_c|FLAG_s|FLAG_z))) { error_exit("Unknown key option."); -- cgit v1.2.3