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

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



On Sep 9,  2:38pm, Eric Pruitt wrote:
} Subject: Re: Running "unset path" breaks PATH despite emulation being enab
}
} I would like to replace "zsh" with the absolute path of the Z shell
} interpreter in case the "zsh" being executed is not the first one listed
} in a $PATH folder. After reading through some documentation and
} reviewing the output of "set", I don't see a way to do this. For
} comparison, Bash sets $BASH to the interpreter's path:

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.

} Is there a similar value in Z shell or a built-in I can use?

$ZSH_ARGZERO in sufficiently recent versions of the shell will give you
the equivalent information, you just have to do the path search part
yourself, which is simple enough with the "=" expander:

[[ =$ZSH_ARGZERO != =$ZSH_NAME ]] && ...

If NO_EQUALS is set then some uses of `whence ...` might be needed.



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