12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- #include "libbb.h"
- int which_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
- int which_main(int argc UNUSED_PARAM, char **argv)
- {
- const char *env_path;
- int status = 0;
- env_path = getenv("PATH");
- if (!env_path)
- env_path = bb_default_root_path;
- getopt32(argv, "^" "a" "\0" "-1");
- argv += optind;
- do {
- int missing = 1;
-
- if (strchr(*argv, '/')) {
- if (file_is_executable(*argv)) {
- missing = 0;
- puts(*argv);
- }
- } else {
- char *path;
- char *tmp;
- char *p;
- path = tmp = xstrdup(env_path);
- while ((p = find_executable(*argv, &tmp)) != NULL) {
- missing = 0;
- puts(p);
- free(p);
- if (!option_mask32)
- break;
- }
- free(path);
- }
- status |= missing;
- } while (*++argv);
- return status;
- }
|