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

Re: The best way to know it is in zsh or bash



On 9/6/19, Peng Yu <pengyu.ut@xxxxxxxxx> wrote:
> Suppose that I start with bash default login shell, then I call zsh.
>
> I'd like to determine whether I am in bash or zsh. I see ZSH_*
> environment variables. Is ZSH_VERSION the most appropriate to be used
> to test whether it is in zsh or not? Thanks.
>
> $ declare -p BASH_VERSION
> declare -- BASH_VERSION="5.0.0(1)-release"
> $ declare -p ZSH_VERSION
> typeset ZSH_VERSION=5.6.2

autotools configure does this, so presumably it works fairly universally,
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :


-- 
Mikael Magnusson



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