/bin/ls sorting bug?

Scott Mitchell scott+freebsd at fishballoon.org
Sat Jun 19 19:43:52 GMT 2004


On Sat, Jun 19, 2004 at 11:47:21AM -0700, Tim Kientzle wrote:
> Scott Mitchell wrote:
> >
> >ls(1) says that the -t option will:
> >
> >     Sort by time modified (most recently modified first) before sort-
> >     ing the operands by lexicographical order.
> >
> >... the attached patch produces the expected output.  I can commit it if 
> >there
> >are no objections.
> 
> Looks good to me.  I wonder if the time sorting should
> include the nanos field as well. (Mostly on FreeBSD,
> the nanos field is zero, but not always.)

I don't see why not, unless some standard requires the nanos to be
ignored.  That would be pretty strange though...

> Of course, sorting on the (non-displayed) nanos field
> could also produce such unexpected output as you describe.

I guess you'd want yet another option to display the full-resolution
timestamp, if you were going to sort on the whole thing.  And you'd still
want to use the name to break ties.

	Scott

-- 
===========================================================================
Scott Mitchell           | PGP Key ID | "Eagles may soar, but weasels
Cambridge, England       | 0x54B171B9 |  don't get sucked into jet engines"
scott at fishballoon.org | 0xAA775B8B |      -- Anon


More information about the freebsd-hackers mailing list