bin/163934: [patch] usbconfig(8) sends help output to stderr instead of stdout

Warren Block wblock at wonkity.com
Tue Jan 10 01:23:14 UTC 2012


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.


More information about the freebsd-bugs mailing list