From 804abb28994ff613c729b2871d002e3540919d9d Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 7 Oct 2022 05:54:20 -0500 Subject: [PATCH] Implement -i option. --- toys/other/lsusb.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/toys/other/lsusb.c b/toys/other/lsusb.c index 382e7a35..3ca7703a 100644 --- a/toys/other/lsusb.c +++ b/toys/other/lsusb.c @@ -109,18 +109,22 @@ static void get_names(struct dev_ids *ids, int id1, int id2, struct dev_ids *parse_dev_ids(char *name, struct dev_ids **and) { char *path = "/etc:/vendor:/usr/share/misc"; - struct string_list *sl; + struct string_list *sl = 0; FILE *fp; char *s, *ss, *sss; struct dev_ids *ids = 0, *new; int fd = -1; // Open compressed or uncompressed file - sprintf(toybuf, "%s.gz", name); - if ((sl = find_in_path(path, toybuf))) { - signal(SIGCHLD, SIG_IGN); - xpopen((char *[]){"zcat", sl->str, 0}, &fd, 1); - } else if ((sl = find_in_path(path, name))) fd = xopen(sl->str,O_RDONLY); + signal(SIGCHLD, SIG_IGN); + s = TT.i; + if (!s) { + sprintf(toybuf, "%s.gz", name); + if ((sl = find_in_path(path, toybuf)) || (sl = find_in_path(path, name))) + s = sl->str; + } + if (s && strend(s, ".gz")) xpopen((char *[]){"zcat", sl->str, 0}, &fd, 1); + else if (s) fd = xopen(s, O_RDONLY); llist_traverse(sl, free); if (fd == -1) return 0; -- 2.39.2