Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uwm.edu!zaphod.mps.ohio-state.edu!think!paperboy!snorkelwacker!spdcc!mirror!ima!minya!jc From: jc@minya.UUCP (John Chambers) Newsgroups: comp.unix.questions Subject: Re: How to get the pathname of the current executable? Summary: which is easy... Message-ID: <110@minya.UUCP> Date: 15 Feb 90 03:31:54 GMT References: <1610.25d028a3@wums.wustl.edu> <1990Feb7.211538.3894@iwarp.intel.com> <5378@buengc.BU.EDU> Lines: 32 > As long as you're still in the directory from which the > program was run, and as long as your path was the same > as the one set in your .cshrc (someone please tell me > why which(1) reads the .cshrc...) then you'll come up > with /usr/foo/bar/bletch/prog, barring surreptition. I've been mystified about this on some Ultrix machines at work, especially since this causes it to give the wrong result most of the time. When I got ahold of this machine (an ESIX system), I was further surprised to find that which didn't even exist. And here I'd thought it was a universal csh builtin. Just shows how naive I was. So I decided to try my hand at implementing it. Half an hour later, I had it working. It works in the obvious way, using the PATH from its environment, and gives the right result. Something even more surprising: You know how the csh builtin has this several-second delay before it answers? Well, my little program answers with no discernable delay. How could they have all gotten it all so wrong? I feel like posting my program, but I'd feel a bit silly to do so, because it's such a piece of trivia. I mean, talk about a Programming 101 assignment. At least, I think I'll take it to work, so I can find things on the Ultrix systems. (Random sounds of disgust and exasperation.) -- John Chambers ...!{harvard,ima,mit-eddie}!minya!jc [Sorry, no clever saying today.]