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

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



On Sun, Sep 10, 2017 at 04:50:57PM -0700, Bart Schaefer wrote:
> On Sep 9,  3:38pm, Eric Pruitt wrote:
> > What want is for Z shell to return is the name to the invoked
> > interpreter which is what $BASH shows even when $PATH doesn't contain
> > Bash.
>
> OK, that's just a little bit trickier.  Here's script equivalent of the
> actual heuristic Bash uses:
>
>   # Set $ZSH the way Bash sets $BASH
>   [...]
>
> This only works if it's executed before any chdir has been done.
>
> For older zsh that don't have the :P modifier, use :A.

Thanks for taking the time to write out that logic. I use Bash almost
exclusively, and it's been interesting seeing how things are done in Z
shell. In the end I settled for this since the script only needs to
support Linux:

    test "${ZSH_NAME:-sh}" = "sh" || exec -a sh /proc/self/exe "$0" "$@"

Of the four shells I'm supporting for the script in question, Z shell is
the only that deviates from POSIX so much that that it requires special
consideration, and I didn't want to add more than a line or two of logic
for it.

Eric



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