bug-fileutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ls -l column alignment patch


From: Andreas Gruenbacher
Subject: ls -l column alignment patch
Date: Fri, 10 Nov 2000 10:09:56 +0100 (CET)

Dear Jim & others,

Here is a patch that improves column alignment for `ls l' output. The
problems addressed are:

 (a) `ls -l' truncates long user/group names
 (b) big file sizes cause mis-alignment in the output
 (c) The mode string has been widened to 11 characters recently, which
     leaves one column less space for the file name. This usually
     is not needed.

The patch keeps columns aligned whenever possible, and long fields never
get truncated. This is done by keeping track of the amount of whitespace
between fields. This space is then used by other fields that are too wide
as needed. The whole thing is implemented as a {sn,f}printf_align function
that keeps some state about alignment between invocations.

Here are some examples:

This is traditional `ls -l' (no space reserved for the '+'):
---------- --- -------- -------- -------- ------------ -------->
drwxr-xr-x  21 longname longgrou     4096 Nov  2 22:32 dir
-rw-r--r--  21 longname longgrou 123456789 Nov  2 22:32 bigfile
-rw-r--r--  21 longname longgrou 1234567890 Nov  2 22:32 biggerfile

This is what the patch does:
---------- --- -------- -------- -------- ------------ -------->
drwxr-xr-x  21 longname1 longgroup   4096 Nov  2 22:32 dir
-rw-r--r--+ 1234 longname1 longgroup  124 Nov  2 22:32 manylinks
-rw-r--r-- 123 name     group   123456789 Nov  2 22:32 bigfile
-rw-r--r--  21 longname1 group 1234567890 Nov  2 22:32 biggerfile

Note that the timestamp and filenames are properly aligned in all cases.


Comments, please?


Thanks,
Andreas.

------------------------------------------------------------------------
 Andreas Gruenbacher, address@hidden
 Contact information: http://www.bestbits.at/~ag/

Attachment: fileutils-4.0.31-align2.patch
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]