GNU bug report logs - #6125
[PATCH] Fix indent of --help and --version

Previous Next

Package: coreutils;

Reported by: Zhang Sen <zh.jesse <at> gmail.com>

Date: Thu, 6 May 2010 12:30:09 UTC

Severity: normal

Tags: notabug, patch

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 6125 <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: Zhang Sen <zh.jesse <at> gmail.com>
Cc: 6125 <at> debbugs.gnu.org
Subject: Re: bug#6125: [PATCH] Fix indent of --help and --version
Date: Thu, 06 May 2010 10:50:22 -0600
[Message part 1 (text/plain, inline)]
On 05/06/2010 02:00 AM, Zhang Sen wrote:
> Hi,
> 
>>From the several commands I tried, HELP_OPTION_DESCRIPTION and
> VERSION_OPTION_DESCRIPTION don't align well with others in the Usage.
> 
> $ cat --help
>   -u                       (ignored)
>   -v, --show-nonprinting   use ^ and M- notation, except for LFD and TAB
>       --help     display this help and exit
>       --version  output version information and exit

First, thanks for taking the time to contribute, and especially for
including a patch.  Too many people make requests with no code to back
it up.  However, I'm hesitant to apply your patch.

I see --help output as having three columns - short options, long
options, and description.  Many options have both short and long (in
your example, -v and --show-nonprinting), some have short only (-u), and
some have long only (--help).  I see nothing wrong with the alignment of
the first two columns in the above example, but agree that the third
column could be better aligned.

I can see your view of --help output having only two columns, and that
the leading - should always be aligned, but I'm not sure I agree with it.

> 
> Here is a trivial patch to make the printing of --help/--version be
> consistent with other options from Usage.
> 
> $ cat --help
>   -u                       (ignored)
>   -v, --show-nonprinting   use ^ and M- notation, except for LFD and TAB
>   --help     display this help and exit
>   --version  output version information and exit

This is a step backwards in my  mind.  It mixes column 1 and 2, rather
than keeping long options in column 2.

> 
> Of course the second column is still broken, but I think that's beyond
> this simple patch.

An even nicer fix would be to write a word-wrapping algorithm, that
takes $COLUMNS into account, and formats all of the columns (short
option, long option, and description) appropriately given the current
screen width and maximum length of the long options column.  But that
means a large rewrite of all of the usage() functions to call this new
formatting system.  It does sound like a nice project, but it's not my
highest priority.

-- 
Eric Blake   eblake <at> redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

This bug report was last modified 14 years and 320 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.