ls patch to sort directories first

Mathieu Arnold mat at FreeBSD.org
Thu Sep 18 03:05:28 PDT 2003


Hi,

a few weeks ago, I had a coworker which wanted to ls and have the
directories listed first...
He ended up with a bash function :

lx() {
        \ls -FGhl "$@" | grep ^d | cat;
        \ls -FGhl "$@" | grep -v '^d\|^t' | cat;
}

I though better of it and cooked up a patch for ls :
<http://people.freebsd.org/~mat/current-ls-D.diff>
<http://people.freebsd.org/~mat/stable-ls-D.diff>

Both do work well, I don't know if it could be included or not, because I
don't really know what's in POSIX.1 and if we're permitted extensions...

For those who will wonder why I used the FTSENT struct and not the stat
struct within it, it's because the stat struct did not seem to be filled
(and I just could not get it to be filled).

Suggestions mostly welcomed :)

-- 
Mathieu Arnold
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20030918/4c5dce2e/attachment.bin


More information about the freebsd-hackers mailing list