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

Re: bash: which: command not found? + (E: Unable to locate package which? ...)



On Fri, 2022-07-08 at 08:37 -0500, Albretch Mueller wrote:
> it seemed to have been somehow
> blanketed by my "unconscious" that bash utils needed to be declared in
> the PATH in order for you to access them.

'which' isn't a 'bash util' whatever that is (presumably you mean a
shell built-in). As you've found out, 'which' is an external program.

To find out how the shell thinks about out a command, use the 'type'
command...

$ type which
which is /usr/bin/which

$ type type
type is a shell builtin

$ type foobar
bash: type: foobar: not found

$ type which
which is hashed (/usr/bin/which)

In the last, 'hashed' sorta means 'cached' so it doesn't have to search
the whole path again to find it. From the posix standard [1]...

   an implementation may remember its location and need not search for the
   utility again unless the PATH variable has been the subject of an
   assignment. If the remembered location fails for a subsequent
   invocation, the shell shall repeat the search to find the new location
   for the utility, if any.

[1] https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/utilities/V3_chap02.html#tag_18_09_01_01

-- 
Tixy


Reply to: