Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Nov 2006 18:40:13 +0100 (CET)
From:      Oliver Fromme <olli@lurza.secnetix.de>
To:        freebsd-arch@FreeBSD.ORG
Subject:   New option for ls(1), du(1), df(1)
Message-ID:  <200611241740.kAOHeDHB072173@lurza.secnetix.de>

next in thread | raw e-mail | index | archive | help
Hi,

I'm not sure if posting to this list is the correct way
to proceed, but the title says "Architecture and design
discussions", and I'm having a design issue, so here it
goes ...

The tools ls(1), du(1) and df(1) all have a "-h" option
which means so-called "human-readable" output.  However,
personally I think the output isn't very human-readable
either way.  You often get a mixture of numbers with
various combinations of "K", "M", "G", and it's difficult
to recognize the dimensions quickly and compare them to
each other.  Just an example:

Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/ad0s1a    989M     61M    849M     7%    /
/dev/ad0s1d    9.7G     31M    8.9G     0%    /var
/dev/ad0s1e    9.7G    1.5G    7.4G    17%    /usr
/dev/ad0s1f    122G    1.3G    111G     1%    /home
/dev/md0       290M     20K    267M     0%    /tmp

I've hacked a new option into those tools which uses
thousands separators for displaying the numbers.  With
that option, the output looks like this (in US locale):

Filesystem    1K-blocks      Used       Avail Capacity  Mounted on
/dev/ad0s1a   1,012,974    62,418     869,520     7%    /
/dev/ad0s1d  10,154,158    31,474   9,310,352     0%    /var
/dev/ad0s1e  10,154,158 1,545,718   7,796,108    17%    /usr
/dev/ad0s1f 128,009,212 1,358,600 116,409,876     1%    /home
/dev/md0        297,326        20     273,520     0%    /tmp

With a German locale (my personal default), periods are
used instead of commas.

The patches for ls(1), du(1) and df(1) are available from
this URL:  http://www.secnetix.de/~olli/FreeBSD/ls-patch/
They apply cleanly to RELENG_6 and RELENG_5.  Except for
df(1) they also apply to HEAD (the df(1) patch requires
a small modification because of the recent addition of the
"kflag" variable in HEAD).

Those patches are not ready yet (that's why i haven't
send-pr'ed them).  They're not checked against style(9),
and the option that I used for the new feature is "-,"
which is probably against style(9), even though it is
easy to remember.  For the same reason I haven't updated
the usage strings and the manpages yet (but I'll do that
when there is consensus).

I have a few questions ...

1.  Which option letter should be used (if not "-,")?
    Currently, the following are unused in ls(1):
    -DEJKMNOQVXYejvyz
    They are also unused in du(1) and df(1), so one of
    those would be fine.

2.  There's a bit of common code in my patches to the
    three utilities.  Should that code be moved to
    libutil?  That's also where humanize_number(3)
    already lives.

It is also worth noting that probably many more tools
might benefit from that feature.  "netstat -i" and
"ipfw show" come to mind immediately.

Any comments are welcome.

Best regards
   Oliver

PS:  I'm reading the list, so there's no need to put me
on CC when replying.

-- 
Oliver Fromme,  secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing
Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.

One Unix to rule them all, One Resolver to find them,
One IP to bring them all and in the zone to bind them.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200611241740.kAOHeDHB072173>