1 /* which - search paths for executable */
11 int main(int argc
, char **argv
);
25 fprintf(stderr
, "Usage: %s cmd [cmd, ..]\n", *av
);
29 for (av
++; *av
; av
++) {
33 if ((path
= getenv("PATH")) == NULL
) {
34 fprintf(stderr
, "Null path.\n");
42 cp
= strchr(path
, DELIMITER
);
48 if (strcmp(path
, "") == 0 && quit
== 0) {
49 sprintf(buf
, "%s./%s", path
, *av
);
51 sprintf(buf
, "%s/%s", path
, *av
);
53 /* Fprintf(stderr,"Trying %s, path %s\n",buf,path); */
57 if (access(buf
, 1) == 0) {
61 sprintf(prog
, "%s.%s", buf
, "prg");
62 if (access(prog
, 1) == 0) {
66 sprintf(prog
, "%s.%s", buf
, "ttp");
67 if (access(prog
, 1) == 0) {
71 sprintf(prog
, "%s.%s", buf
, "tos");
72 if (access(prog
, 1) == 0) {
78 fprintf(stderr
, "No %s in %s\n", *av
, getenv("PATH"));