bug-bash
[Top][All Lists]
Advanced

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

Re: bug? "type -P xxx" returns "xxx" that isn't executable...(or readabl


From: Chet Ramey
Subject: Re: bug? "type -P xxx" returns "xxx" that isn't executable...(or readable)
Date: Fri, 01 Aug 2014 09:37:58 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.6.0

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    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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