On 8/1/14, 2:40 AM, Linda Walsh wrote:
> 
> 
> Chet Ramey wrote:
>> type -P echo
>>
>> ls -l $(type -P echo)
>>
>>
>> If you already have `echo' in the command hash table, type -P will return
>> it, since that's what the shell will attempt to execute.
> ---
>     It's not in the hash table, but type -P still
> returns the non-executable.

OK, I see what's happening.  In the absence of a hashed command, bash will
return the first executable with the given name found in $PATH.  If there
are no executables with that name in $PATH, but bash finds a
non-executable file by that name, bash will return (and attempt to
execute) it.  Bash has behaved this way for many years.

In case you're wondering, shell behavior in this area varies widely.  Bash,
dash, zsh, and the 7th edition sh attempt to execute the non-executable
file; ksh93, mksh, and the SVR4.2 sh report not found.

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

Reply via email to