Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: The best way to know it is in zsh or bash
- X-seq: zsh-users 24229
- From: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>
- To: Peng Yu <pengyu.ut@xxxxxxxxx>
- Subject: Re: The best way to know it is in zsh or bash
- Date: Fri, 6 Sep 2019 20:02:29 +0100
- Cc: zsh-users <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=rxG+ZPJdGWXKXjfgD+8JKhevKsG21ojuJXWK4eKbN7A=; b=L76IUS9Oydiz1wazKZhFNsXCeToAUtRrhXKVnew8GpI0z0wbB8dAUvgcBWzKanvFhI sf8yGbMSHgw9FDYcrzHAmr2iUS12iRbyE5U5qHhF6PtbCX6C/OaAvV1L8Hys1oIKONv4 wxrt/Kbt0wQaocsgnZGLLtReDPVZQVuuN9nwAk+xX8C6813LkE6kzArQPu5xb+xHjyuQ XeDTbnv8/TsFcjw9JD2fiOZ6Vre1s5/aO4vJsO+4jYMpMWHt9OC947SaWwPtK8V6u3bJ HgXKwD+6+ha1IhuqGsBaOp3ggyfPZwMmfBN8N5/IU00fNGsKVznDo/shfKRsLTl0fGM3 Njvg==
- In-reply-to: <CABrM6w=5V8VnJcX0SNj0s8+EpyJWFqN7EYTYc51rNpTYQ_p9vw__33715.8397933067$1567780959$gmane$org@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mail-followup-to: Peng Yu <pengyu.ut@xxxxxxxxx>, zsh-users <zsh-users@xxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author