bin/62911: usbdevs feature: add one-line output suitable for
grepping
Corris Randall
corris at line6.net
Mon Feb 16 06:30:08 PST 2004
>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: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Mon Feb 16 06:30:07 PST 2004
>Closed-Date:
>Last-Modified:
>Originator: Corris Randall <corris at 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 at 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:
>Unformatted:
More information about the freebsd-bugs
mailing list