commit e0cc79528c41671e4420b75e8612313203629fe5
parent c301cfe257c1af054f920f190f0acc5e2003dcb4
Author: aabacchus <ben@bvnf.space>
Date: Fri, 21 Apr 2023 22:37:04 +0100
search multiple pkgs
Diffstat:
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/search.c b/src/search.c
@@ -4,13 +4,15 @@
int
search(int argc, char **argv, struct env *e) {
- char **s = find_in_path(argv[1], e->kiss_path, false);
- if (s == NULL)
- die2(argv[1], "not found");
- for (int i = 0; s[i] != NULL; i++) {
- printf("%s\n", s[i]);
- free(s[i]);
+ for (int i = 1; i < argc; i++) {
+ char **s = find_in_path(argv[i], e->kiss_path, false);
+ if (s == NULL)
+ die2(argv[i], "not found");
+ for (int j = 0; s[j] != NULL; j++) {
+ printf("%s\n", s[j]);
+ free(s[j]);
+ }
+ free(s);
}
- free(s);
return 0;
}