[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [leafnode-list] running leafnode and fetchnews

Nick Drage <nick-drage@xxxxxx> wrote:
> when I install software into directories that are in my $PATH I have
> to logout and log back in on a particular console before it'll
> recognise the new programs within the $PATH.
> Not quite sure why this is, maybe someone can enlighten me?

It depends on the shell, and whether there are other programs in the
path with the same name.

Some shells hash each command word when you first use it.  When you
first type a path-searched command, like
    grep 'HOT XXX BABES' /newsspool/comp/compilers/*
it'll look up "grep" in $PATH and store the location in a hash table.
Future runs of the same command word, like
    grep 'FORTRAN cross-compilers' /newsspool/alt/sex/computers/sapient/evil/*
will go to the hashed location, and it won't look thru $PATH.  This is
all fine and good until you put a new "grep" in $PATH ahead of the
existing one.  The shell won't see it.

I suppose there may be shells that hash all of PATH the first time it's
set, so if you ever add a command *anywhere* in PATH it won't be seen.

Logging out and logging in is certainly an effective way to make the
shell sit up and take notice (the hash table is in memory, so when the
process ends, it's lost, and a new process has to build it anew), but
it's rather drastic.  See the documentation for the shell you use, and
experiment at need.  In the Korn shell on my ISP's Solaris, it's
    hash -r
to flush the hash table.  On the AIX bash at work, it's the same, and
    set -d
disables hashing for the rest of the shell session.

I believe
would probably work in most shells.  The shell could notice "the new
value is equivalent to the old, so ignore it", but more likely it'll
just see that PATH is changed and therefore the fundamental assumption
of the hash table is invalid -- that is, it has to flush the hash

Tim McDaniel is tmcd@xxxxxxxx; if that fail,
    tmcd@xxxxxxxxxx is my work account.

leafnode-list@xxxxxxxxxxxxxxxxxxxxxxxxxxxx -- mailing list for leafnode
To unsubscribe, send mail with "unsubscribe" in the subject to the list