delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/01/09/00:49:07

From: frederic DOT corne AT erli DOT fr (Frederic Corne)
Subject: Re: "which" command
9 Jan 1997 00:49:07 -0800 :
Sender: daemon AT cygnus DOT com
Approved: cygnus DOT gnu-win32 AT cygnus DOT com
Distribution: cygnus
Message-ID: <9701090734.AA15472.cygnus.gnu-win32@orme.sunserv>
Reply-To: frederic DOT corne AT erli DOT fr
Original-To: gnu-win32 AT cygnus DOT com
In-Reply-To: <199701082214.RAA13874@sol.pinebush.com> (message from Ed Huott
on Wed, 08 Jan 1997 17: 14:41 -0500)
Original-Sender: owner-gnu-win32 AT cygnus DOT com

> From: Ed Huott <huott AT pinebush DOT com>
> In message <32D3EA6F DOT 901 AT infoscape DOT com>, Justin Gordon writes:
> >is there an implementation of "which"
> >
> >or is there a way to make find only search in the path?
> >
> There is a built-in command in the bash shell called `type' that will
> perform the equivalent of `which'. 

> There is also a native NT version of `which' called NTWHICH.EXE which is
> probably downloadable from any of the popular shareware sites.  It's
> freeware (GPL) authored by Jack J. Woehr.
> 

Yes this is not the right mailing-list, but ...

If you use nt-emacs, there is a little fonction from Peter Breton, which
avoid to use a sub-process :

;; By Peter Breton <pbreton AT i-kinetics DOT com>
(defun which (exe &optional showall)
  "Show the full path name of an executable.
This command searches the directories in `exec-path'"
  (interactive "sWhich: ")
  (catch 'answer
    (mapcar
     '(lambda (dir)
	(mapcar
	 '(lambda (suf)
	    (let ((try (expand-file-name (concat exe suf) dir)))
	      (and (file-executable-p try)
		   (null (file-directory-p try))
		   (progn
		     (message "%s is %s" exe try)
		     (throw 'answer try)))))
	 '("")))
     exec-path)
    (message "Can't find %s in search path" exe)
    nil))

-- 

****  Frederic CORNE   GSI-ERLI  frederic DOT corne AT erli DOT fr ****
-
For help on using this list, send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


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