bug-textutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug in "sort" program


From: Harry Rarig
Subject: Bug in "sort" program
Date: Mon, 19 Feb 2001 08:15:59 -0500

Gnu-Guys:

I dunno, but somehow this looks like a bug to me.
Does this look like a bug to you, or am I making some bad assumptions
here...?

address@hidden SortBugs]$ cat /etc/issue

Red Hat Linux release 6.2 (Zoot)
Kernel 2.2.14-5.0 on an i586

address@hidden SortBugs]$ 

Here are the files to sort:

address@hidden SortBugs]$ cat foo1
1-2-1-4-4
1-2-1-4-3
1-2-1-4-2
1-2-1-4-1
1-2-1-4
address@hidden SortBugs]$ cat foo2
1-2-1-4-4:
1-2-1-4-3:
1-2-1-4-2:
1-2-1-4-1:
1-2-1-4:
address@hidden SortBugs]$ cat foo3
1-2-1-4-4:a
1-2-1-4-3:b
1-2-1-4-2:c
1-2-1-4-1:d
1-2-1-4:e
address@hidden SortBugs]$ 


Now, lets sort these files using ":" as the key delimeter

TEST #1
address@hidden SortBugs]$ sort -d -t: -k1 foo1
1-2-1-4
1-2-1-4-1
1-2-1-4-2
1-2-1-4-3
1-2-1-4-4

Yeah, I expected this result, lets move on to the next...

TEST #2
address@hidden SortBugs]$ sort -d -t: -k1 foo2
1-2-1-4:
1-2-1-4-1:
1-2-1-4-2:
1-2-1-4-3:
1-2-1-4-4:

Still lookin' good, next...

TEST #3
address@hidden SortBugs]$ sort -d -t: -k1 foo3
1-2-1-4-1:d
1-2-1-4-2:c
1-2-1-4-3:b
1-2-1-4-4:a
1-2-1-4:e

Whoa!  Not what I expected!  Lets look at foo2 again, without
alphanumeric key restriction...

TEST #4
address@hidden SortBugs]$ sort  -t: -k1 foo2
1-2-1-4-1:
1-2-1-4-2:
1-2-1-4-3:
1-2-1-4-4:
1-2-1-4:

Well, OK, I guess so, but ":" is the delimeter, so why is it being
considered in the sort?  

Now another sanity check on key position "2"

TEST #5
address@hidden SortBugs]$ sort -d -t: -k2 foo3
1-2-1-4-4:a
1-2-1-4-3:b
1-2-1-4-2:c
1-2-1-4-1:d
1-2-1-4:e
address@hidden SortBugs]$ 

Looks OK to me...



QUESTION:  Can you explain what is happening in TEST #3 and TEST #4?  Is
this expected behavior, or a bug?

tnx,

Harry


-- 
Harry Rarig                        _/  _/   _/    _/_/_/  _/_/_/  _/  _/
Tellium Inc.                      _/_/_/ _/_/_/  _/_/_/  _/_/_/    _/
732 923-4249 Voice               _/  _/ _/  _/ _/   _/ _/   _/    _/
732 923-9804 Fax                ___________________________________/

System Test  ====>>  "We break the things that make communications work"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]