summaryrefslogtreecommitdiff
path: root/debianutils/which.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-12-27 04:35:04 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-12-27 04:35:04 +0000
commit8d42f86b146871ae4c4cafd3801a85f381249a14 (patch)
treeb963999fc54eddb65f1929b894f868e24851fc9c /debianutils/which.c
downloadbusybox-w32-8d42f86b146871ae4c4cafd3801a85f381249a14.tar.gz
busybox-w32-8d42f86b146871ae4c4cafd3801a85f381249a14.tar.bz2
busybox-w32-8d42f86b146871ae4c4cafd3801a85f381249a14.zip
Correcting branch name to be like previous ones
Diffstat (limited to 'debianutils/which.c')
-rw-r--r--debianutils/which.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/debianutils/which.c b/debianutils/which.c
new file mode 100644
index 000000000..a715a2664
--- /dev/null
+++ b/debianutils/which.c
@@ -0,0 +1,43 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * Which implementation for busybox
4 *
5 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
6 * Copyright (C) 2006 Gabriel Somlo <somlo at cmu.edu>
7 *
8 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
9 *
10 * Based on which from debianutils
11 */
12
13#include "busybox.h"
14
15int which_main(int argc, char **argv)
16{
17 int status = EXIT_SUCCESS;
18 char *p;
19
20 if (argc <= 1 || argv[1][0] == '-') {
21 bb_show_usage();
22 }
23
24 while (--argc > 0) {
25 argv++;
26 if (strchr(*argv, '/')) {
27 if (execable_file(*argv)) {
28 puts(*argv);
29 continue;
30 }
31 } else {
32 p = find_execable(*argv);
33 if (p) {
34 puts(p);
35 free(p);
36 continue;
37 }
38 }
39 status = EXIT_FAILURE;
40 }
41
42 fflush_stdout_and_exit(status);
43}