Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Running "unset path" breaks PATH despite emulation being enabled



On 9/9/17 6:25 PM, Bart Schaefer wrote:

> I just had a look at the Bash sources.  Chet will correct me if I'm wrong,
> but as far as I can tell if argv[0] is not already at least a partial
> path, then $BASH is set by doing a path search for the first matching
> executable.  Thus $BASH will be "the first one listed in a $PATH folder" 
> when argv[0] contains no "/" separators, even if the actual executable
> came from somewhere else.

This is about the best you can do. The only additional thing would be to
assume that the executed binary came from the current directory if you
can't find it in $PATH, because that's how execve(2) and its siblings work.
It's a heuristic based on how the shell is commonly executed, but it can
certainly be fooled.

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



Messages sorted by: Reverse Date, Date, Thread, Author