diff options
author | le <le@FreeBSD.org> | 2004-05-24 13:22:00 +0000 |
---|---|---|
committer | le <le@FreeBSD.org> | 2004-05-24 13:22:00 +0000 |
commit | 7983c5d70f9db3d88b7514164f95e84de5ee7e0d (patch) | |
tree | cf21e8ef1e915de46a48da9cfa4a820812aef3e5 /usr.sbin | |
parent | 12a8a7fa4c0109f2026bc038e210787355416bf2 (diff) | |
download | FreeBSD-src-7983c5d70f9db3d88b7514164f95e84de5ee7e0d.zip FreeBSD-src-7983c5d70f9db3d88b7514164f95e84de5ee7e0d.tar.gz |
Add option '-o' for one-line output in combination with '-d'.
PR: bin/62911 (patch slightly adopted)
Submitted by: Corris Randall <corris@line6.net>
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/usbdevs/usbdevs.8 | 6 | ||||
-rw-r--r-- | usr.sbin/usbdevs/usbdevs.c | 25 |
2 files changed, 24 insertions, 7 deletions
diff --git a/usr.sbin/usbdevs/usbdevs.8 b/usr.sbin/usbdevs/usbdevs.8 index fb2f87a..3226dd5 100644 --- a/usr.sbin/usbdevs/usbdevs.8 +++ b/usr.sbin/usbdevs/usbdevs.8 @@ -34,7 +34,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 15, 2000 +.Dd May 24, 2004 .Dt USBDEVS 8 .Os .Sh NAME @@ -45,6 +45,7 @@ .Op Fl a Ar addr .Op Fl d .Op Fl f Ar dev +.Op Fl o .Op Fl v .Sh DESCRIPTION The @@ -61,6 +62,9 @@ only print information about the device at the given address. Show the device drivers associated with each device. .It Fl f Ar dev only print information for the given USB controller. +.It Fl o +One-line output (only useful in combination with +.Fl d ) . .It Fl v Be verbose. .El diff --git a/usr.sbin/usbdevs/usbdevs.c b/usr.sbin/usbdevs/usbdevs.c index 0cda38d..640dd51 100644 --- a/usr.sbin/usbdevs/usbdevs.c +++ b/usr.sbin/usbdevs/usbdevs.c @@ -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,22 @@ usbdev(int f, int a, int rec) 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]); + for (i = 0; i < USB_MAX_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,7 +187,7 @@ main(int argc, char **argv) int addr = 0; int ncont; - while ((ch = getopt(argc, argv, "a:df:v?")) != -1) { + while ((ch = getopt(argc, argv, "a:df:ov?")) != -1) { switch(ch) { case 'a': addr = atoi(optarg); @@ -188,6 +198,9 @@ main(int argc, char **argv) case 'f': dev = optarg; break; + case 'o': + oneline++; + break; case 'v': verbose = 1; break; |