bin/81625: "sort by size" option for ls(1)

Giorgos Keramidas keramida at freebsd.org
Wed Jun 1 04:50:06 PDT 2005


The following reply was made to PR bin/81625; it has been noted by GNATS.

From: Giorgos Keramidas <keramida at freebsd.org>
To: Dima Dorfman <dd at freebsd.org>
Cc: mplekos at physics.upatras.gr, FreeBSD-gnats-submit at freebsd.org
Subject: Re: bin/81625: "sort by size" option for ls(1)
Date: Wed, 1 Jun 2005 14:40:14 +0300

 On 2005-06-01 11:25, Dima Dorfman <dd at freebsd.org> wrote:
 > Giorgos Keramidas <keramida at FreeBSD.org> wrote:
 > > >Description:
 > >
 > > Kostas Blekos <mplekos at physics.upatras.gr> has mailed me with a patch
 > > to ls(1) that allows sorting the output files by size:
 >
 > Cool, looks like a nice improvement. Some minor comments below. Part
 > of the man page update seems to be missing, and I want to change the
 > default polarity, but the rest are just minor style nits.
 >
 > > The -S option is not exactly optimal, but there are so many option
 > > letters that are taken by existing ls(1) features that there isn't
 > > much of a choise, unless we modify ls to use something like -o for
 > > picking a selection order:
 >
 > -S is okay. OpenBSD and NetBSD use it for the same thing, except that
 > their default is to sort the largest files first.
 >
 >      -S      Sort by size, largest file first.
 >
 > Can we change the patch to do that? I'm not sure why they picked
 > descending order, but compatibility would be good here.
 
 Agreed.
 
 > > +
 > > +int
 > > +sizecmp(const FTSENT *a, const FTSENT *b)
 > > +{
 > > +	if (b->fts_statp->st_size > a->fts_statp->st_size)
 > > +		return (-1);
 >
 > Style nit: Please add a blank line above the if. If a function has no
 > local variables, there should still be a blank line after the brace.
 > (See the usage() example in style(9).)
 
 I know.  I just patched a local bin/ls and tried that it all works, so
 style changes like those you mentioned are perfectly fine :-)
 


More information about the freebsd-bugs mailing list