help-bash
[Top][All Lists]
Advanced

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

Re: Help-bash Digest, Vol 144, Issue 20


From: Greg Wooledge
Subject: Re: Help-bash Digest, Vol 144, Issue 20
Date: Sat, 2 Dec 2023 17:33:54 -0500

On Sun, Dec 03, 2023 at 05:22:41AM +0700, Budi wrote:
> is Bash' hash just do faster path's lookup or really answer/solve the above
> discussion.. please elaborate it

The hash command is a shell builtin which is required by POSIX, and
implemented by bash, with extensions.

POSIX documentation:
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/hash.html

Fundamentally, it tells you whether your shell has remembered the PATH
to a given program, in case you have installed a different version of
it somewhere else which you'd like your shell to use instead.  (Or if
you've modified your PATH.)  In that case, you can tell your shell to
forget the remembered location and perform a new search for said program.

Shells remember the locations of things they've had to search for in
your PATH for efficiency.  Repeating a search across many directories
is inefficient, given that programs *very* rarely move.  If you're using
a super-fast solid state disk, you may not care about this.  Back in
the old days, searching for a program across many directories took a
significant amount of time -- especially if some of those directories
were mounted on network shares.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]