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: Mon, 19 Dec 2022 11:17:55 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.6.0

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.

How's this: -P skips everything but hashed pathnames and path searches, and
unless -a is supplied, stops at the first pathname that will be executed
for a given NAME. -p does path searches, and, unless -a is supplied, shows
you what would be executed (and hashed) for a given NAME as long as nothing
else would take precedence over it.

Then we can change the behavior of `type -ap' and `type -aP', which are
sort of orthogonal to the rest of `type'. We don't really need to change
`type -ap', but we can add a PATH search to a successful hash table
lookup for `type -aP'.

--
``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]