[PATCH] flexi-sized user/group/size fields for ls

Ralf Friedl Ralf.Friedl at online.de
Sat Jan 16 13:17:19 UTC 2010


Ian Wienand wrote:
> I found that with large files and long username/group names,
> everything runs together.  e.g.
>
> wienandi at coopers:~/programs/busybox$ ./busybox_old ls -l ./big 
> -rw-r--r--    1 Debian-e Debian-e1099511627777 Jan 15 11:50 ./big
>
> Major problem is that this kills scripts that parse the output.
The problem is the missing space between group and size.
> @@ -828,12 +877,15 @@ static NOINLINE unsigned list_single(const 
> struct dnode *dn)
>                     (int) minor(dn->dstat.st_rdev));
>         } else {
>             if (all_fmt & LS_DISP_HR) {
> -                column += printf("%9s ",
> +                column += printf("%*s ",
> +                         size_width,
>                     /* print st_size, show one fractional, use 
> suffixes */
The reason is that the size is printed without leading space after the 
group. So the simple fix would be to change the printf format from "%9s" 
to "[space]%8s", with explicit space before the format, instead of 
relying on the space being part of the padding. Or the space might be 
added after the group name. This would add one single extra byte.

Of course, the variable width is also a nice feature.

Regards
Ralf


More information about the busybox mailing list