bug-bash
[Top][All Lists]
Advanced

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

Re: hash not restored after running command -p


From: Mike Jonkmans
Subject: Re: hash not restored after running command -p
Date: Sun, 31 Oct 2021 15:47:59 +0100

On Sun, Oct 31, 2021 at 03:33:07PM +0300, Oğuz wrote:
> 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.

It might indeed be convenient.
Using the hash as alias for commands, that are not in your PATH,
seems risky though.

> > 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:

Oops, missed that. Thanks.

It is indeed there, under 1.e.i in
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_01_01

-- 
Regards, Mike Jonkmans



reply via email to

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