Path: utzoo!utgpu!cs.utexas.edu!rice!uw-beaver!milton!hayes.ims.alaska.edu!lll-winken!uunet!mcsun!hp4nl!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: alt.sources.d Subject: Re: which() (was Re: Multiple executables in path) Message-ID: <8905@star.cs.vu.nl> Date: 31 Jan 91 18:42:12 GMT References: <17687:Jan2414:33:5091@kramden.acf.nyu.edu> <4545@softway.sw.oz.au> Sender: news@cs.vu.nl Reply-To: maart@cs.vu.nl (Maarten Litmaath) Organization: VU Dept. of Computer Science, Amsterdam, The Netherlands Lines: 29 In article <4545@softway.sw.oz.au>, peterc@softway.sw.oz.au (Peter Chubb) writes: )My favourite solution, for the Bourne shell, at least, is: ) )#!/bin/sh )# which -- print full pathname of executable args. ) )for i )do ) IFS=":" ) for j in $PATH ) do ) test -x $j/$i && echo $j/$i ) exit 0 ) done )done )exit 1 This script doesn't work at all! You meant this: test -x $j/$i && { echo $j/$i exit 0 } Furthermore this script has the same problems as other scripts that invoke `test', as discussed before. -- Temporary files like /tmp/sh$$ are an abomination.