zsh-users
 help / Atom feed
From: Stephane Chazelas <stephane.chazelas@gmail.com>
To: Peng Yu <pengyu.ut@gmail.com>
Cc: zsh-users <zsh-users@zsh.org>
Subject: Re: The best way to know it is in zsh or bash
Date: Fri, 6 Sep 2019 20:02:29 +0100
Message-ID: <20190906190229.ouynwukrobao3cbq@chaz.gmail.com> (raw)
In-Reply-To: <CABrM6w=5V8VnJcX0SNj0s8+EpyJWFqN7EYTYc51rNpTYQ_p9vw__33715.8397933067$1567780959$gmane$org@mail.gmail.com>

2019-09-06 09:41:22 -0500, Peng Yu:
> 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
[...]

Just run ps or maybe ps -H (HP/UX, procps):

~$ ps -H
  PID TTY          TIME CMD
32057 pts/13   00:00:00 zsh
32123 pts/13   00:00:00   ps
~$ bash
bash-4.4$ ps -H
  PID TTY          TIME CMD
32057 pts/13   00:00:00 zsh
32124 pts/13   00:00:00   bash
32125 pts/13   00:00:00     ps

ps -o comm= -p "$$"

Will show you the name of the process of id $$ (the pid that executed the
shell).

-- 
Stephane

      parent reply index

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-06 14:41 Peng Yu
2019-09-06 15:11 ` René Wilhelm
2019-09-06 15:38   ` Peng Yu
2019-09-06 15:51     ` gi1242+zsh
2019-09-06 15:16 ` Mikael Magnusson
2019-09-06 17:41 ` Bart Schaefer
     [not found] <CABrM6w=5V8VnJcX0SNj0s8+EpyJWFqN7EYTYc51rNpTYQ_p9vw__33715.8397933067$1567780959$gmane$org@mail.gmail.com>
2019-09-06 19:02 ` Stephane Chazelas [this message]

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190906190229.ouynwukrobao3cbq@chaz.gmail.com \
    --to=stephane.chazelas@gmail.com \
    --cc=pengyu.ut@gmail.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

zsh-users

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-users

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.users


AGPL code for this site: git clone https://public-inbox.org/ public-inbox