diff options
author | Matt Kraai <kraai@debian.org> | 2000-11-18 01:16:43 +0000 |
---|---|---|
committer | Matt Kraai <kraai@debian.org> | 2000-11-18 01:16:43 +0000 |
commit | 768a2340b557f01738bf5944463a6fc4d70f0b21 (patch) | |
tree | 1cedde1670a2b5b71523e8954f72e18c01b80bac | |
parent | e93abf9e6997f333c5add8f11b1542bbc2ccc844 (diff) | |
download | busybox-w32-768a2340b557f01738bf5944463a6fc4d70f0b21.tar.gz busybox-w32-768a2340b557f01738bf5944463a6fc4d70f0b21.tar.bz2 busybox-w32-768a2340b557f01738bf5944463a6fc4d70f0b21.zip |
Fixed return status (thanks to David Douthitt for the fix).
-rw-r--r-- | findutils/which.c | 8 | ||||
-rw-r--r-- | which.c | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/findutils/which.c b/findutils/which.c index da8801fab..a92777eb7 100644 --- a/findutils/which.c +++ b/findutils/which.c | |||
@@ -28,7 +28,7 @@ extern int which_main(int argc, char **argv) | |||
28 | { | 28 | { |
29 | char *path_list, *path_n; | 29 | char *path_list, *path_n; |
30 | struct stat filestat; | 30 | struct stat filestat; |
31 | int i, count=1; | 31 | int i, count=1, found, status = EXIT_SUCCESS; |
32 | 32 | ||
33 | if (argc <= 1 || **(argv + 1) == '-') | 33 | if (argc <= 1 || **(argv + 1) == '-') |
34 | usage(which_usage); | 34 | usage(which_usage); |
@@ -48,6 +48,7 @@ extern int which_main(int argc, char **argv) | |||
48 | while(argc-- > 0) { | 48 | while(argc-- > 0) { |
49 | path_n = path_list; | 49 | path_n = path_list; |
50 | argv++; | 50 | argv++; |
51 | found = 0; | ||
51 | for (i = 0; i < count; i++) { | 52 | for (i = 0; i < count; i++) { |
52 | char buf[strlen(path_n)+1+strlen(*argv)]; | 53 | char buf[strlen(path_n)+1+strlen(*argv)]; |
53 | strcpy (buf, path_n); | 54 | strcpy (buf, path_n); |
@@ -57,12 +58,15 @@ extern int which_main(int argc, char **argv) | |||
57 | && filestat.st_mode & S_IXUSR) | 58 | && filestat.st_mode & S_IXUSR) |
58 | { | 59 | { |
59 | printf ("%s\n", buf); | 60 | printf ("%s\n", buf); |
61 | found = 1; | ||
60 | break; | 62 | break; |
61 | } | 63 | } |
62 | path_n += (strlen(path_n) + 1); | 64 | path_n += (strlen(path_n) + 1); |
63 | } | 65 | } |
66 | if (!found) | ||
67 | status = EXIT_FAILURE; | ||
64 | } | 68 | } |
65 | return(TRUE); | 69 | return status; |
66 | } | 70 | } |
67 | 71 | ||
68 | /* | 72 | /* |
@@ -28,7 +28,7 @@ extern int which_main(int argc, char **argv) | |||
28 | { | 28 | { |
29 | char *path_list, *path_n; | 29 | char *path_list, *path_n; |
30 | struct stat filestat; | 30 | struct stat filestat; |
31 | int i, count=1; | 31 | int i, count=1, found, status = EXIT_SUCCESS; |
32 | 32 | ||
33 | if (argc <= 1 || **(argv + 1) == '-') | 33 | if (argc <= 1 || **(argv + 1) == '-') |
34 | usage(which_usage); | 34 | usage(which_usage); |
@@ -48,6 +48,7 @@ extern int which_main(int argc, char **argv) | |||
48 | while(argc-- > 0) { | 48 | while(argc-- > 0) { |
49 | path_n = path_list; | 49 | path_n = path_list; |
50 | argv++; | 50 | argv++; |
51 | found = 0; | ||
51 | for (i = 0; i < count; i++) { | 52 | for (i = 0; i < count; i++) { |
52 | char buf[strlen(path_n)+1+strlen(*argv)]; | 53 | char buf[strlen(path_n)+1+strlen(*argv)]; |
53 | strcpy (buf, path_n); | 54 | strcpy (buf, path_n); |
@@ -57,12 +58,15 @@ extern int which_main(int argc, char **argv) | |||
57 | && filestat.st_mode & S_IXUSR) | 58 | && filestat.st_mode & S_IXUSR) |
58 | { | 59 | { |
59 | printf ("%s\n", buf); | 60 | printf ("%s\n", buf); |
61 | found = 1; | ||
60 | break; | 62 | break; |
61 | } | 63 | } |
62 | path_n += (strlen(path_n) + 1); | 64 | path_n += (strlen(path_n) + 1); |
63 | } | 65 | } |
66 | if (!found) | ||
67 | status = EXIT_FAILURE; | ||
64 | } | 68 | } |
65 | return(TRUE); | 69 | return status; |
66 | } | 70 | } |
67 | 71 | ||
68 | /* | 72 | /* |