hi

sort -k has a bug when the start character of the field is specified but
the end character is not

eg. sort -k 1.2,1

sort returns 'field out of order' but the end character defaults to 0,
which signifies the last character of the field and so is definitely not
out of order. a check for start char being less than end char does not take
this into account

patch to fix the issue:

Index: init.c
===================================================================
RCS file: /cvs/src/usr.bin/sort/init.c,v
retrieving revision 1.13
diff -u -p -r1.13 init.c
--- init.c      28 Nov 2013 18:24:55 -0000      1.13
+++ init.c      29 Dec 2014 02:01:38 -0000
@@ -176,6 +176,7 @@ setfield(char *pos, struct field *cur_fl
                cur_fld->flags &= (D|F|I|N|R|BI);
        if (cur_fld->tcol.num && !(!(cur_fld->flags & BI)
            && cur_fld->flags & BT) && (cur_fld->tcol.num <=
cur_fld->icol.num
+           && cur_fld->tcol.indent > 0
            && cur_fld->tcol.indent < cur_fld->icol.indent))
                errx(2, "fields out of order");
        insertcol(cur_fld);

Reply via email to