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

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

I'm moving this discussion from zsh-workers to zsh-users since it's been
established that the behavior I observed isn't necessarily a bug.

On Fri, Sep 08, 2017 at 01:30:05PM +0200, Mikael Magnusson wrote:
> This works fine if you start zsh as sh though, ie either make a
> symlink ln -s =zsh sh; ./sh or do ARGV0=sh zsh
> It can't really work in the 'emulate sh' case since the parameter
> $path is then already created and it would be quite controversial for
> emulate to remove parameters from the shell environment.

What I ended up doing is adding this to the top of my script:

    test "${ZSH_NAME:-sh}" = "sh" || exec -a sh zsh "$0" "$@"

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:

    ~$ echo $BASH

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


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