help-bash
[Top][All Lists]
Advanced

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

Re: type -aP: intentional behaviour or a bug?


From: Chet Ramey
Subject: Re: type -aP: intentional behaviour or a bug?
Date: Tue, 27 Dec 2022 14:57:33 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.6.0

On 12/19/22 8:17 PM, Adam Vodopjan wrote:


On 19/12/2022 18:17, Chet Ramey wrote:
On 12/16/22 7:33 PM, Adam Vodopjan wrote:


Bash man page: 'If a command is hashed, -p and -P print the hashed value',
but it says later: 'The table of hashed commands is not consulted when
using -a'.

Right, unless -P is supplied to force it.

It looks like a 20 yo bug, or a problem with docs. '-a' states for
'everything', not for 'everything, if only it is not hashed yet in case of
-P. But with -p it is everything indeed'.

Then let's see if we can rationalize the behavior. They have to differ,
otherwise there's no reason to have both.

As per type.def, -p vs -P is CDESC_FORCE_PATH flag. With it enabled:

Thanks for the summary of current (bash-5.2) behavior.


I think the only thing to change is dropping the CDESC_FORCE_PATH
condition from the hash block. So that it is never entered with -a.

I think something different: keep the same condition, but keep going if
`all' != 0 (-a supplied). -P then gives you the hash table lookup plus
the path search; -p gives you a path search only.

The idea is that you can use -P to skip everything but the first occurrence
in the file system (including existing hash table entries), and -p to get
to the first thing that will be executed, including a hash table entry.

Maybe another change is to allow -ap to search the hash table, if it
gets that far, by changing the flag to CDESC_PATH_ONLY.


--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/




reply via email to

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