[Top][All Lists]

[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: Linda Walsh
Subject: Re: bug? "type -P xxx" returns "xxx" that isn't executable...(or readable)
Date: Thu, 31 Jul 2014 23:40:18 -0700
User-agent: Thunderbird

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.

Ishtar:/> ll {,/usr}/bin/echo
-rw-r--r-- 2 136753 Nov 19  2013 /bin/echo
--w------- 2 136753 Nov 19  2013 /usr/bin/echo
sudo chmod +x /bin/echo
Ishtar:/> type -P echo
/bin/echo                                       #correct
Ishtar:/> sudo chmod -x /bin/echo            #take it away
Ishtar:/> hash -r                            #in theory, purge command hash
Ishtar:/> type -P echo                       #but doesn't use last lookup
/usr/bin/echo                                   #switches to returning /usr/bin 

Assuming my hash -r was ignored, and -P would
still deliver the last command used, it should have returned
/bin/echo... but "/bin/echo" is no longer readable

Shouldn't it return "null" or empty string?

i.e. I thought I could check for an executable by doing
a lookup with -P (not for builtins, obviously) for non
builtins, seems that's not safe?  Shouldn't it be?

reply via email to

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