diff options
author | Rob Landley <rob@landley.net> | 2008-05-17 17:52:51 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2008-05-17 17:52:51 -0500 |
commit | 59f490cb4e18960e7ddd003f9a66005eccc5ebd7 (patch) | |
tree | 5e9af2b4cdd2387f8eea377c3d9c8c2662e9e1b5 /toys | |
parent | 1a221d9b4f058d05aa250691c381f0cfeaaeab9e (diff) | |
download | toybox-59f490cb4e18960e7ddd003f9a66005eccc5ebd7.tar.gz |
Fix which (the meaning of -a was reversed, and it was finding the _last_ hit).
Diffstat (limited to 'toys')
-rw-r--r-- | toys/which.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/toys/which.c b/toys/which.c index 63e12aa4..13198363 100644 --- a/toys/which.c +++ b/toys/which.c @@ -6,7 +6,7 @@ * * Not in SUSv3. -USE_WHICH(NEWTOY(which, "a", TOYFLAG_USR|TOYFLAG_BIN)) +USE_WHICH(NEWTOY(which, "<1a", TOYFLAG_USR|TOYFLAG_BIN)) config WHICH bool "which" @@ -20,8 +20,6 @@ config WHICH */ #include "toys.h" -#define OPT_a 1 - // Find an exectuable file either at a path with a slash in it (absolute or // relative to current directory), or in $PATH. Returns absolute path to file, // or NULL if not found. @@ -54,7 +52,7 @@ static int which_in_path(char *filename) if (!access(list->str, X_OK)) { puts(list->str); // If we should stop at one match, do so - if (toys.optflags & OPT_a) { + if (!toys.optflags) { llist_free(list, NULL); break; } @@ -67,10 +65,7 @@ static int which_in_path(char *filename) void which_main(void) { - if (!*toys.optargs) toys.exitval++; - else { - int i; - for (i=0; toys.optargs[i]; i++) - toys.exitval |= which_in_path(toys.optargs[i]); - } + int i; + for (i=0; toys.optargs[i]; i++) + toys.exitval |= which_in_path(toys.optargs[i]); } |