From corris@corris.org  Mon Feb 16 06:28:31 2004
Return-Path: <corris@corris.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id A8CB616A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 16 Feb 2004 06:28:31 -0800 (PST)
Received: from fry.corris.org (unknown [204.1.128.34])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 718D543D1F
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 16 Feb 2004 06:28:31 -0800 (PST)
	(envelope-from corris@corris.org)
Received: from corris.org (localhost [127.0.0.1])
	by fry.corris.org (8.12.10/8.12.10) with ESMTP id i1EHrQ9x001451
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 14 Feb 2004 09:53:26 -0800 (PST)
	(envelope-from corris@corris.org)
Received: (from root@localhost)
	by corris.org (8.12.10/8.12.10/Submit) id i1EHrQYx001450;
	Sat, 14 Feb 2004 09:53:26 -0800 (PST)
	(envelope-from corris)
Message-Id: <200402141753.i1EHrQYx001450@corris.org>
Date: Sat, 14 Feb 2004 09:53:26 -0800 (PST)
From: Corris Randall <corris@line6.net>
Reply-To: Corris Randall <corris@line6.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: usbdevs feature: add one-line output suitable for grepping
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         62911
>Category:       bin
>Synopsis:       usbdevs feature: add one-line output suitable for grepping
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Feb 16 06:30:07 PST 2004
>Closed-Date:    Mon May 24 06:23:00 PDT 2004
>Last-Modified:  Mon May 24 06:23:00 PDT 2004
>Originator:     Corris Randall <corris@line6.net>
>Release:        FreeBSD 5.2-RC2 i386
>Organization:
Line 6
>Environment:
System: FreeBSD fry.corris.org 5.2-RC2 FreeBSD 5.2-RC2 #0: Thu Jan 8 20:08:46 GMT 2004 root@fry.corris.org:/usr/obj/usr/src/sys/FRY i386


>Description:
	the output of usbdevs -d puts the device name on another line, this makes it lame to grep for. ( possible, just a pain in the ass ).  Rather than "fixing" it, I opted for adding -o ( feel free to change, I don't care what the argument is ) to make -d append ", device udriver0" to the line. 
>How-To-Repeat:
	N/A
>Fix:

--- usbdevs_oneline.udiff begins here ---
diff -u -r usbdevs/usbdevs.8 usbdevs_new/usbdevs.8
--- usbdevs/usbdevs.8	Sat Feb 14 09:28:39 2004
+++ usbdevs_new/usbdevs.8	Sat Feb 14 09:40:47 2004
@@ -46,6 +46,7 @@
 .Op Fl d
 .Op Fl f Ar dev
 .Op Fl v
+.Op Fl o
 .Sh DESCRIPTION
 The
 .Nm
@@ -63,6 +64,8 @@
 only print information for the given USB controller.
 .It Fl v
 Be verbose.
+.It Fl o
+print info all on one line ( really only useful with -d ).
 .El
 .Sh SEE ALSO
 .Xr usb 4
diff -u -r usbdevs/usbdevs.c usbdevs_new/usbdevs.c
--- usbdevs/usbdevs.c	Sat Feb 14 09:28:39 2004
+++ usbdevs_new/usbdevs.c	Sat Feb 14 09:42:43 2004
@@ -54,6 +54,7 @@
 
 int verbose = 0;
 int showdevs = 0;
+int oneline = 0;
 
 void usage(void);
 void usbdev(int f, int a, int rec);
@@ -109,13 +110,19 @@
 		       di.udi_vendor, di.udi_vendorNo, di.udi_release);
 	} else
 		printf("%s, %s", di.udi_product, di.udi_vendor);
-	printf("\n");
+	if ( ! oneline )
+		printf("\n");
 	if (showdevs) {
 		for (i = 0; i < USB_MAX_DEVNAMES; i++)
-			if (di.udi_devnames[i][0])
-				printf("%*s  %s\n", indent, "",
-				       di.udi_devnames[i]);
+			if (di.udi_devnames[i][0]) {
+				if ( oneline )
+					printf(", device %s", di.udi_devnames[i]);
+				else 
+					printf("%*s  %s\n", indent, "", di.udi_devnames[i]);
+			}
 	}
+	if ( oneline )
+		printf("\n");
 	if (!rec)
 		return;
 	for (p = 0; p < di.udi_nports; p++) {
@@ -177,13 +184,16 @@
 	int addr = 0;
 	int ncont;
 
-	while ((ch = getopt(argc, argv, "a:df:v?")) != -1) {
+	while ((ch = getopt(argc, argv, "a:dof:v?")) != -1) {
 		switch(ch) {
 		case 'a':
 			addr = atoi(optarg);
 			break;
 		case 'd':
 			showdevs++;
+			break;
+		case 'o':
+			oneline++;
 			break;
 		case 'f':
 			dev = optarg;
--- usbdevs_oneline.udiff ends here ---


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: le 
State-Changed-When: Mon May 24 06:22:31 PDT 2004 
State-Changed-Why:  
Thank you, provided patch slightly modified and committed. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=62911 
>Unformatted:
