From nobody@FreeBSD.org  Sun Feb 29 11:41:08 2004
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 2A7FD16A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 29 Feb 2004 11:41:08 -0800 (PST)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 0C03043D1F
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 29 Feb 2004 11:41:08 -0800 (PST)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.10/8.12.10) with ESMTP id i1TJf772071444
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 29 Feb 2004 11:41:07 -0800 (PST)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.10/8.12.10/Submit) id i1TJf7Bk071443;
	Sun, 29 Feb 2004 11:41:07 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200402291941.i1TJf7Bk071443@www.freebsd.org>
Date: Sun, 29 Feb 2004 11:41:07 -0800 (PST)
From: Heiko Braun <bsd@heiko-braun.de>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Just a suggestion for the output of the 'ls -lah' command
X-Send-Pr-Version: www-2.3

>Number:         63547
>Category:       bin
>Synopsis:       Just a suggestion for the output of the 'ls -lah' command
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    cperciva
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Feb 29 11:50:13 PST 2004
>Closed-Date:    Mon Mar 01 11:26:16 PST 2004
>Last-Modified:  Mon Mar 01 11:26:16 PST 2004
>Originator:     Heiko Braun
>Release:        5.2-RELEASE
>Organization:
>Environment:
FreeBSD HEIKO-PC 5.2-RELEASE FreeBSD 5.2-RELEASE #0: Sun Jan 11 04:21:45 GMT 2004     root@wv1u.btc.adaptec.com:/usr/obj/usr/src/sys/GENERIC  i386
>Description:
I'd like to make some suggestion concerning the appearing of the
output of the "ls" command.
In detail, the output of "ls -lah" concerning the "-h" flag and the
size of the file displayed.

First, the list is not always column-aligned.
(sorry, can't express better what I mean, see example below).
And second, I don't think that a floating point output of files smaller
than 10 Bytes makes sense.

original ls -lah:
drwxr-xr-x   2 heiko  heiko  512B 29 Feb 20:11 .
drwxr-xr-x  36 heiko  heiko  4,0K 29 Feb 19:26 ..
-rw-r--r--   1 heiko  heiko    0B 29 Feb 20:08 file_with_0_byte
-rw-r--r--   1 heiko  heiko  977K 29 Feb 20:11 file_with_1000000_byte
-rw-r--r--   1 heiko  heiko  1000B 29 Feb 20:09 file_with_1000_byte
-rw-r--r--   1 heiko  heiko  100B 29 Feb 20:08 file_with_100_byte
-rw-r--r--   1 heiko  heiko  1000K 29 Feb 20:11 file_with_1024000_byte
-rw-r--r--   1 heiko  heiko  10,0B 29 Feb 20:08 file_with_10_byte
-rw-r--r--   1 heiko  heiko  1,0B 29 Feb 20:08 file_with_1_byte
-rw-r--r--   1 heiko  heiko  1,9M 29 Feb 20:11 file_with_2000000_byte
-rw-r--r--   1 heiko  heiko  2,0K 29 Feb 20:09 file_with_2000_byte

Changed one:
-rw-r--r--   1 heiko  heiko     0B 29 Feb 20:08 file_with_0_byte
-rw-r--r--   1 heiko  heiko   977K 29 Feb 20:11 file_with_1000000_byte
-rw-r--r--   1 heiko  heiko  1000B 29 Feb 20:09 file_with_1000_byte
-rw-r--r--   1 heiko  heiko   100B 29 Feb 20:08 file_with_100_byte
-rw-r--r--   1 heiko  heiko  1000K 29 Feb 20:11 file_with_1024000_byte
-rw-r--r--   1 heiko  heiko    10B 29 Feb 20:08 file_with_10_byte
-rw-r--r--   1 heiko  heiko     1B 29 Feb 20:08 file_with_1_byte
-rw-r--r--   1 heiko  heiko   1,9M 29 Feb 20:11 file_with_2000000_byte
-rw-r--r--   1 heiko  heiko   2,0K 29 Feb 20:09 file_with_2000_byte
>How-To-Repeat:
Type 'ls -lah' in a directory with files which size is displayed with a 4 digit number and/or file size is below 10 bytes.
>Fix:
I'd suggest to change the code in /usr/src/bin/ls/print.c in
function "printsize" the lines 626-630 from:
		if (dbytes == 0)
			(void)printf("%*s ", 4, "0B");
		else
			(void)printf("%*.*f%c ", 3,
			    dbytes > 10 ? 0 : 1, dbytes, "BKMGTPE"[unit]);

to:
		if (unit == 0)
			(void)printf("%*d%c ", 4, (int)dbytes, 'B');
		else
			(void)printf("%*.*f%c ", 4,
			    dbytes > 10 ? 0 : 1, dbytes, "BKMGTPE"[unit]);
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->cperciva 
Responsible-Changed-By: cperciva 
Responsible-Changed-When: Sun Feb 29 18:19:03 PST 2004 
Responsible-Changed-Why:  
I broke this, I guess I'd better fix it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=63547 
State-Changed-From-To: open->closed 
State-Changed-By: cperciva 
State-Changed-When: Mon Mar 1 11:25:55 PST 2004 
State-Changed-Why:  
Fixed (I think). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=63547 
>Unformatted:
