From mbadolato@cheekon.com  Sun Nov 16 00:00:16 2003
Return-Path: <mbadolato@cheekon.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 9D64D16A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 16 Nov 2003 00:00:16 -0800 (PST)
Received: from cheekon.com (radsl-bady-03.phx.gblx.net [207.218.25.210])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 7BA6543FCB
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 16 Nov 2003 00:00:15 -0800 (PST)
	(envelope-from mbadolato@cheekon.com)
Received: from cheekon.com (localhost [127.0.0.1])
	by cheekon.com (8.12.9p1/8.12.9) with ESMTP id hAG7roHw028399
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 16 Nov 2003 00:53:51 -0700 (MST)
	(envelope-from mbadolato@cheekon.com)
Received: (from mbadolato@localhost)
	by cheekon.com (8.12.9p1/8.12.9/Submit) id hAG7roEu028347;
	Sun, 16 Nov 2003 00:53:50 -0700 (MST)
Message-Id: <200311160753.hAG7roEu028347@cheekon.com>
Date: Sun, 16 Nov 2003 00:53:50 -0700 (MST)
From: Mark Badolato <mbadolato@cybernox.com>
Reply-To: Mark Badolato <mbadolato@cybernox.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: Using ls -h (on FBSD 5.x) causes unaligned formatting	
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         59320
>Category:       bin
>Synopsis:       Using ls -h (on FBSD 5.x) causes unaligned formatting
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    cperciva
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Nov 16 00:10:16 PST 2003
>Closed-Date:    Wed Jan 21 20:40:18 PST 2004
>Last-Modified:  Wed Jan 21 20:40:18 PST 2004
>Originator:     Mark Badolato
>Release:        FreeBSD 5.1-RELEASE-p10 i386
>Organization:
>Environment:
System: FreeBSD mail.XXXYYY.com 5.1-RELEASE-p10 FreeBSD 5.1-RELEASE-p10 #0: Sun Nov 16 00:25:54 MST 2003 mbadolato@cybernox.com:/usr/obj/usr/src/sys/AXE i386


	
>Description:
On 5.x systems, using ls with the -h switch causes columns to line up incorrectly, as the size column is not right-justified.
>How-To-Repeat:
execute an ls command with the -h option:
-bash-2.05b$ ls -lh      
total 6
-rwx------  1 root       mbadolato  59B Nov 15 18:37 cvs.sh
-rwxr-xr-x  1 mbadolato  mbadolato  51B Nov 15 18:37 new_ports.sh
drwxr-xr-x  2 mbadolato  mbadolato  512B Nov 16 00:42 source
-bash-2.05b$ ls -l 
total 6
-rwx------  1 root       mbadolato   59 Nov 15 18:37 cvs.sh
-rwxr-xr-x  1 mbadolato  mbadolato   51 Nov 15 18:37 new_ports.sh
drwxr-xr-x  2 mbadolato  mbadolato  512 Nov 16 00:42 source


>Fix:

	


>Release-Note:
>Audit-Trail:

From: Ryan Sommers <ryans@gamersimpact.com>
To: freebsd-gnats-submit@FreeBSD.org, mbadolato@cybernox.com
Cc:  
Subject: [PATCH] Re: bin/59320: Using ls -h (on FBSD 5.x) causes unaligned formatting
Date: Fri, 21 Nov 2003 15:30:50 -0600

 Patch to fix formatting. I don't see why the "-1" was added, but taking it out 
 of the printing seems to do the trick, I tested it on a few different 
 directory structures and seems to work.
 
 --- /usr/src/bin/ls/print.c	Wed Nov 19 21:04:58 2003
 +++ /usr/src/bin/ls/print.c	Fri Nov 21 15:01:25 2003
 @@ -626,7 +626,7 @@
  		if (dbytes == 0)
  			(void)printf("%*s ", (u_int)width, "0B");
  		else
 -			(void)printf("%*.*f%c ", (u_int)width - 1,
 +			(void)printf("%*.*f%c ", (u_int)width,
  			    dbytes > 10 ? 0 : 1, dbytes, "BKMGTPE"[unit]);
  	} else
  		(void)printf("%*jd ", (u_int)width, bytes);
 
 -- 
 Ryan "leadZERO" Sommers
 Gamer's Impact President
 ryans@gamersimpact.com
 ICQ: 1019590
 AIM/MSN: leadZERO
 
 -= http://www.gamersimpact.com =-
 

From: Mark Badolato <mbadolato@cybernox.com>
To: freebsd-gnats-submit@FreeBSD.org, mbadolato@cybernox.com
Cc:  
Subject: Re: bin/59320: Using ls -h (on FBSD 5.x) causes unaligned
  formatting
Date: Thu, 11 Dec 2003 20:27:22 -0700

 Still not working, 5.2-RC1
 
 bash-2.05b# ls -lh
 total 20
 -rw-r--r--  1 mbadolato  mbadolato  767B Dec 11 11:12 .cshrc
 -rw-r--r--  1 mbadolato  mbadolato  248B Dec 11 11:12 .login
 -rw-r--r--  1 mbadolato  mbadolato  158B Dec 11 11:12 .login_conf
 -rw-------  1 mbadolato  mbadolato  373B Dec 11 11:12 .mail_aliases
 -rw-r--r--  1 mbadolato  mbadolato  331B Dec 11 11:12 .mailrc
 -rw-r--r--  1 mbadolato  mbadolato  797B Dec 11 11:12 .profile
 -rw-------  1 mbadolato  mbadolato  276B Dec 11 11:12 .rhosts
 -rw-r--r--  1 mbadolato  mbadolato  975B Dec 11 11:12 .shrc
 -rwx------  1 root       mbadolato  59B Dec 11 20:15 cvs.sh
 -rw-r--r--  1 root       mbadolato  52B Dec 11 20:15 new_ports.sh
 
 
 
Responsible-Changed-From-To: freebsd-bugs->cperciva 
Responsible-Changed-By: cperciva 
Responsible-Changed-When: Wed Jan 21 19:00:58 PST 2004 
Responsible-Changed-Why:  
I'm going to grab this PR. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=59320 

From: Colin Percival <colin.percival@wadham.ox.ac.uk>
To: freebsd-gnats-submit@FreeBSD.org, mbadolato@cybernox.com
Cc:  
Subject: Re: bin/59320: Using ls -h (on FBSD 5.x) causes unaligned
  formatting
Date: Thu, 22 Jan 2004 04:06:28 +0000

    This is actually just a small part of a larger problem: The
 width parameter should be ignored completely for human-readable
 output, as shown by the following example:
 
 -bash-2.05b$ ls -lh /var/tmp/
 total 12306
 -rw-r--r--  1 cperciva  wheel       12M Jan 22 04:06 bigfile
 drwxrwxrwt  2 root      wheel      512B Jan 20 23:14 vi.recover
                                ^^^^ extra space.
 
    The width here is set to strlen("12000000"), while for `ls -lh`
 it should just be fixed at 4.
 
 Colin Percival
 
State-Changed-From-To: open->closed 
State-Changed-By: cperciva 
State-Changed-When: Wed Jan 21 20:37:15 PST 2004 
State-Changed-Why:  
Fixed, thanks. 


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