🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix
Article #466

Re: hash in /bin/sh

#466
From: Lukas
Date: Fri, 23 Oct 1987 16:06
46 lines
2451 bytes
Thanks to Kevin Bond, Fred Christiansen, Ed Nieters, and Martin
Davidson for their replys.

I was informed that the hash behevior that I described was documented
(sort of). So, seeking the last refuge of the incompetent :^) I RTFMd
and found:

	The location in the search path where a command was found is
	remembered by the shell (to help avoid unnecessary execs later).
	If the command was found in a relative directory, its location
	must be re-determined whenever the current directory changes.

This appearently means that having . in your $PATH causes any command
path that follows . to be reevaluated on each invocation, to see if
it is now in ., or elsewhere. I guess this makes sense, because the
reason that I have . first in my $PATH is so that the directories
over which I have the most control are searched first. More specifically,
my $PATH looks like:

	.:`logdir lukas`/bin:/bin: etc.

This allows me, for example, to have an ed that "remembers" the name
of the last file edited, so that a simple succeeding "ed" will cause
"/bin/ed last-file" to be invoked. Not earth shaking (except in
California) I know, but its the little things . . .  :^)

This raises a couple of further questions:

	1) Is this constant reevaluation of command paths more expensive
	than it is worth? (I detect no unacceptable degredation in
	interactive performance).

	2) Is my thinking about the set up of my $PATH flawed? (Please
	no comments about the rest of my thinking) Is there a better way?

	3) Is there any way (short of changing the path) to prevent the
	shell from reevaluating each command each time that it is invoked.
	This would be useful when creating a shell script that might
	loop through a series of commands a large number of times.

Any further replies will be appreciated. How am I doing?
-- 

	John Lukas
	ihnp4!ihlpf!lukas
	312-510-6290
Technical Details
Message-ID: <2136@mcdchg.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!hao!ames!lll-tis!mordor!sri-spam!rutgers!gatech!mcdchg!usenet
References: <2056@mcdchg.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!hao!ames!lll-tis!mordor!sri-spam!rutgers!gatech!mcdchg!usenet
From: lukas@ihlpf.ATT.COM (Lukas)
Newsgroups: comp.unix
Subject: Re: hash in /bin/sh
Message-ID: <2136@mcdchg.UUCP>
Date: Fri, 23-Oct-87 11:06:58 EST
Article-I.D.: mcdchg.2136
Posted: Fri Oct 23 11:06:58 1987
Date-Received: Sun, 25-Oct-87 22:45:24 EST
References: <2056@mcdchg.UUCP>
Sender: usenet@mcdchg.UUCP
Organization: AT&T Bell Laboratories
Lines: 46
Approved: usenet@mcdchg.UUCP