Re: [dev] Re: [dev] [dev] Usage, -h, --help, help, synopsis, …

From: Kris Maglione <maglione.k_AT_gmail.com>
Date: Tue, 17 Aug 2010 23:27:58 -0400

On Tue, Aug 17, 2010 at 07:54:44PM -0700, Suraj Kurapati wrote:
>On Tue, Aug 17, 2010 at 8:40 AM, Alexander Teinum <ateinum_AT_gmail.com> wrote:
>> What is the most concise way of outputting a usage and help text?
>
>For my programs, the --help option simply displays their manpage. :-)
>
>man(1) is better suited for information display (text-wrapping to 80
>characters or $COLUMNS, pagination, and emphasis with bold, reverse
>video, underline, etc.) than anything I could care to reinvent poorly
>in each of my programs.

GNU man has the annoying and difficult to stop habit of filling
the entire width of the terminal rather than wrapping at 80
chars. And if you set $MANWIDTH or $COLUMNS to 80 and the
terminal isn't that wide, you wind up with badly broken
wrapping. As for bold, fortunately my terminal has it disabled,
and reverse video has no place in manual pages.

By the way, this is the script I use to launch man. If anyone
knows of something better (other than Plan 9 man which
unfortunately can't handle system man pages), please tell me:

#!/bin/rc
*=`{stty size} {
        cols = $2
}

MANWIDTH=`{9 bc<<!}
        if($cols >= 72) print 72
        if($cols < 72) {
                if($cols >= 65) print 65
                if($cols < 65) print $cols
        }
!
exec /usr/bin/man $* | 9 tr − - | less

-- 
Kris Maglione
He hoped and prayed that there wasn't an afterlife.  Then he realized
there was a contradiction involved here and merely hoped that there
wasn't an afterlife.
	--Douglas Adams
Received on Wed Aug 18 2010 - 05:27:58 CEST

This archive was generated by hypermail 2.2.0 : Wed Aug 18 2010 - 05:36:02 CEST