Subject: Re: ls -lsh
To: None <tech-userlevel@netbsd.org>
From: Jan Schaumann <jschauma@netmeister.org>
List: tech-userlevel
Date: 08/05/2004 23:14:14
--24zk1gE8NUlDmwG9
Content-Type: multipart/mixed; boundary="h31gzZEtNLTqOjlF"
Content-Disposition: inline
--h31gzZEtNLTqOjlF
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
cgd@broadcom.com wrote:
> At Thu, 5 Aug 2004 20:26:33 +0000 (UTC), "Jan Schaumann" wrote:
> > 'ls -ls' makes sense. But 'ls -lhs' doesn't show anything that 'ls -lh'
> > doesn't already provide. (At least ours doesn't.)
>=20
> That's a bug. the behaviour that seems to have been observed with GNU
> ls (i.e., shows a human-readable byte count for each size) is what I'd
> consider right.
How about this, then?
-Jan
--=20
If you are undertaking anything substantial, C is the only reasonable choice
of programming language.
-- UNIX User's Supplementary Documents
--h31gzZEtNLTqOjlF
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=diff
Content-Transfer-Encoding: quoted-printable
Index: print.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/src/bin/ls/print.c,v
retrieving revision 1.38
diff -b -u -r1.38 print.c
--- print.c 26 Dec 2003 06:19:19 -0000 1.38
+++ print.c 6 Aug 2004 03:03:22 -0000
@@ -96,11 +96,19 @@
=20
if (dp->list->fts_level !=3D FTS_ROOTLEVEL && (f_longform || f_size)) {
if (f_humanize) {
- if ((humanize_number(szbuf, sizeof(szbuf), dp->stotal,
- "", HN_AUTOSCALE,
+ int64_t total;
+
+ if (f_size)=20
+ total =3D 1024 * howmany(dp->btotal, blocksize);
+ else
+ total =3D dp->stotal;
+
+ if ((humanize_number(szbuf, sizeof(szbuf),
+ total, "", HN_AUTOSCALE,
(HN_DECIMAL | HN_B | HN_NOSPACE))) =3D=3D -1)
err(1, "humanize_number");
(void)printf("total %s\n", szbuf);
+
} else {
(void)printf("total %llu\n",
(long long)(howmany(dp->btotal, blocksize)));
@@ -114,9 +122,19 @@
if (f_inode)
(void)printf("%*lu ", dp->s_inode,
(unsigned long)sp->st_ino);
- if (f_size && !f_humanize) {
+ if (f_size) {
+ if (f_humanize) {
+ if ((humanize_number(szbuf, sizeof(szbuf),
+ 1024 * howmany(sp->st_blocks, blocksize),
+ "", HN_AUTOSCALE,
+ (HN_DECIMAL | HN_B | HN_NOSPACE))) =3D=3D -1)
+ err(1, "humanize_number");
+ (void)printf("%*s ", dp->s_block + 1, szbuf);
+ } else {
(void)printf("%*llu ", dp->s_block,
- (long long)howmany(sp->st_blocks, blocksize));
+ (long long)howmany(sp->st_blocks,=20
+ blocksize));
+ }
}
(void)strmode(sp->st_mode, buf);
np =3D p->fts_pointer;
--h31gzZEtNLTqOjlF--
--24zk1gE8NUlDmwG9
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)
iD8DBQFBEveGfFtkr68iakwRArdcAKD5H/rmeGeO47KyK8ZJBtHJoV27fACePBQ8
SmPg7VTh+o1McZRIzrYqI30=
=pevw
-----END PGP SIGNATURE-----
--24zk1gE8NUlDmwG9--