home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sources.misc
- organization: VU Informatika, Amsterdam, The Netherlands
- subject: v11i096: which5
- From: maart@cs.vu.nl (Maarten Litmaath)
- Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
-
- Posting-number: Volume 11, Issue 96
- Submitted-by: maart@cs.vu.nl (Maarten Litmaath)
- Archive-name: which5/part01
-
- There was still a small problem with which4. :-(
- Thanks go to Jim Meyering <meyering@cs.utexas.edu>, who noted convert() will
- clobber the stack if the PATH is longer than BUF_SIZE - 1 characters.
- I've changed the use and implementation of convert() altogether: now it
- returns a path vector (cf. argv), whose components are the respective
- directories in the PATH.
- Furthermore I fixed the printing of the PATH: there are no trailing colons
- anymore. Now you can do things like:
-
- for dir in `which`
- do
- set $dir/$pattern
- test -f $1 || continue
- for i
- do
- echo $i
- done
- done
-
- ...to find all files in your PATH which match $pattern.
- However, beware of rewriting `which' in shell-script! There were good
- reasons for making it a C program (check the source).
-
- Thanks for your time,
- Maarten Litmaath @ VU Amsterdam:
- maart@cs.vu.nl, uunet!mcsun!botter!maart
-
-