Mail Archives: djgpp/1998/06/19/16:46:19
>>>>> "Eli" == Eli Zaretskii writes:
Eli, why this program if we already have ported `which'?
>> Next question : Is there any command available like 'which' in UNIX
>> ?
Eli> You can easily write it yourself, using the library function
Eli> __dosexec_find_on_path. For example (untested!):
Eli> #include <stdio.h> #include <stdlib.h> #include
Eli> <libc/dosexec.h>
Eli> int main (int argc, char *argv[]) { char
Eli> full_path[FILENAME_MAX]; extern char **environ;
Eli> if (argc <= 1) { printf ("Usage: %s progname\n", argv[0]);
Eli> return 0; }
Eli> if (__dosexec_find_on_path (argv[1], (char **)0, full_path)
Eli> == NULL && __dosexec_find_on_path (argv[1], environ, full_path)
Eli> == NULL) printf ("%s: Command not found\n", argv[1]); else printf
Eli> ("%s\n", full_path);
Eli> return 0; }
/Oleg
- Raw text -