delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/19/16:46:19

From: luke AT jet DOT msk DOT su (Oleg Yu. Polyanski)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: using redir
Date: 19 Jun 1998 13:18:55 +0400
Organization: Jet Infosystems
Lines: 27
Message-ID: <huulnqtrbpc.fsf@goliath.jet.msk.su>
References: <Pine DOT SUN DOT 3 DOT 91 DOT 980618145728 DOT 24854B-100000 AT is>
NNTP-Posting-Host: goliath.service.jet.msk.su
Mime-Version: 1.0 (generated by tm-edit 7.108)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

>>>>> "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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019