Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 9 Jan 2012 17:54:55 -0700 (MST)
From:      Warren Block <wblock@wonkity.com>
To:        Bruce Evans <brde@optusnet.com.au>
Cc:        freebsd-bugs@freebsd.org, freebsd-gnats-submit@freebsd.org
Subject:   Re: bin/163934: [patch] usbconfig(8) sends help output to stderr instead of stdout
Message-ID:  <alpine.BSF.2.00.1201091514320.33267@wonkity.com>
In-Reply-To: <20120109183017.T1220@besplex.bde.org>
References:  <201201082105.q08L5EXm038909@red.freebsd.org> <20120109183017.T1220@besplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 9 Jan 2012, Bruce Evans wrote:

> On Sun, 8 Jan 2012, Warren Block wrote:
>
>>> Description:
>> usbconfig(8)'s -h option prints output to stderr.  This output is not due 
>> to an error, and is already 28 lines line.  A typical terminal will not 
>> display it all, so the user has to redirect stderr to view it with less or 
>> other utilities.
>>> How-To-Repeat:
>> usbconfig -h | less  (then try to scroll back)
>>> Fix:
>> Apply attached patch.
>> 
>> Patch attached with submission follows:
>> 
>> Index: usbconfig.c
>> ===================================================================
>> --- usbconfig.c	(revision 229822)
>> +++ usbconfig.c	(working copy)
>> @@ -265,7 +265,7 @@
>> static void
>> usage(void)
>> {
>> -	fprintf(stderr, ""
>> +	fprintf(stdout, ""
>> 	    "usbconfig - configure the USB subsystem" "\n"
>> 	    "usage: usbconfig -u <busnum> -a <devaddr> -i <ifaceindex> 
>> [cmds...]" "\n"
>> 	    "usage: usbconfig -d [ugen]<busnum>.<devaddr> -i <ifaceindex> 
>> [cmds...]" "\n"
>
> This breaks the normal use of usage() for usage errors.

Yes.  My fault, I hadn't thought of that, er, usage of usage().  If 
usage() output is caused by an error, it should go to stderr, to keep it 
"out of band" of stdout.

The user can request usage() output with -h or --help or something
equivalent, and that output should go to stdout because it's not an 
error and that data is what was requested.  IMO, of course.

usbconfig doesn't actually have a -h option, usage() output is just a 
default fall-through.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.BSF.2.00.1201091514320.33267>