[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: hash not restored after running command -p
From: |
Oğuz |
Subject: |
Re: hash not restored after running command -p |
Date: |
Sun, 31 Oct 2021 15:33:07 +0300 |
On Sun, Oct 31, 2021 at 2:15 PM Mike Jonkmans <bashbug@jonkmans.nl> wrote:
> PATH=/dev/null
> command -p hostname
> hostname # executes /bin/hostname via the hash table
>
> I agree with OP that the behaviour is a bug, or at least unwanted behaviour.
I'd say it's a feature, and a good one too. Not having to prefix each
invocation of a utility with `command -p ' is a convenience if there's
a lot of them.
>
> I could not find this in POSIX nor in the bash manual, but it seems true:
> Assignment to PATH clears the hash table.
> (Even when the value stays the same).
It's in XCU 2.9.1.4:
> Once a utility has been searched for and found (either as a result of this
> specific search or as part of an unspecified shell start-up activity), an
> implementation may remember its location and need not search for the
> utility again unless the PA TH 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.
- hash not restored after running command -p, Roger Morris, 2021/10/29
- Re: hash not restored after running command -p, Chet Ramey, 2021/10/30
- Re: hash not restored after running command -p, Mike Jonkmans, 2021/10/31
- Re: hash not restored after running command -p,
Oğuz <=
- Re: hash not restored after running command -p, Mike Jonkmans, 2021/10/31
- Re: hash not restored after running command -p, Oğuz, 2021/10/31
- Re: hash not restored after running command -p, Mike Jonkmans, 2021/10/31
- Re: hash not restored after running command -p, Oğuz, 2021/10/31
- Re: hash not restored after running command -p, Mike Jonkmans, 2021/10/31
Re: hash not restored after running command -p, Roger Morris, 2021/10/31