www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/18/08:10:02

Date: Thu, 18 Jun 1998 15:09:31 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Michael Hecht <michael DOT hecht AT dillinger DOT de>
cc: djgpp AT delorie DOT com
Subject: Re: using redir
In-Reply-To: <3588EAD1.2F1C@dillinger.de>
Message-ID: <Pine.SUN.3.91.980618145728.24854B-100000@is>
MIME-Version: 1.0

On Thu, 18 Jun 1998, Michael Hecht wrote:

> Next question : Is there any command available like 'which' in UNIX ?

You can easily write it yourself, using the library function 
__dosexec_find_on_path.  For example (untested!):

  #include <stdio.h>
  #include <stdlib.h>
  #include <libc/dosexec.h>

  int main (int argc, char *argv[])
  {
     char full_path[FILENAME_MAX];
     extern char **environ;

     if (argc <= 1)
       {
	 printf ("Usage: %s progname\n", argv[0]);
	 return 0;
       }

     if (__dosexec_find_on_path (argv[1], (char **)0, full_path) == NULL &&
	 __dosexec_find_on_path (argv[1], environ, full_path) == NULL)
       printf ("%s: Command not found\n", argv[1]);
     else
       printf ("%s\n", full_path);

     return 0;
  }

- Raw text -


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