From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 78d31685 for ; Fri, 6 Sep 2019 17:42:48 +0000 (UTC) Received: (qmail 15005 invoked by alias); 6 Sep 2019 17:42:37 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 24224 Received: (qmail 22196 invoked by uid 1010); 6 Sep 2019 17:42:37 -0000 X-Qmail-Scanner-Diagnostics: from mail-lf1-f41.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.2/25559. spamassassin: 3.4.2. Clear:RC:0(209.85.167.41):SA:0(-1.9/5.0):. Processed in 2.020063 secs); 06 Sep 2019 17:42:37 -0000 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.167.41 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4U9FEjjv/htYmDUQL4ZKAF7F4iP6JY4WcYHSmwTfz9A=; b=1gEK21oRWnGXp25+JJEatJOcSfZi+Ks9iwMVSqtsgLeEPMTxpF4eSp7reoWs127dDm pkdVqjRC/fKbo6Z+gcQEjOV58DwbVDEOVnx+XQkq+UXOW3u4pjNCxDlYNeD+P61nZEd4 7FLn2s/Q518KujPmXKSk1oLBOsqRlor8b+sPHzVilM5zzfSB7PiQc4as3OWcDEyVULX9 GYZelLUgHu1JcsIqhgzmok6hOdVGq216gzDugt2k92cNGszXLXj33DEx8fx4Rnlwirpd OMFsY2WRyXo/zqiJq795jBHspQmCEoVi3KaVyC1TO2pvV4bCH3EVYr8Q5tdnnMR4QEWu E/0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4U9FEjjv/htYmDUQL4ZKAF7F4iP6JY4WcYHSmwTfz9A=; b=CmXTax06Q+kC1XzmER5eQ3AIkAopyjK0R6vkbk9seYqUPE4YQgKmT5DnuqG/kQ4jbp zsBjkdcdGtLtzCLgHKfzIfGgS0oKzX3rdX53pZe8VY5E4mFlxogjsGvgOx+uq6YwBB42 qltdnfQsi7bqQkiH/WEkU8lWeBjn/UhSfv31dFDkvxTOeAISP0W3yXMxslYjWBC/7H7k EUK8Nx8Qv/ygN87rAacUBoJKlGlAO4jyIBUvINR9Dh4XY44imNW8TlrtQm6S1/QkfNHV 9br5mm54hKxR9AvJfX0TNgK9QH0fQNtQjpOMHTlN7BRLePB3qmzfWWZji09uf7WBzqDs pXEQ== X-Gm-Message-State: APjAAAXM/KeiKYBm5F06Ptn/dHfpXQLJpAXH8Pn/46D6fj/9f4oBnofq lx6wICf/lf5S4odeTFHjbl7OG8IfccvnInvnz3nJ9A== X-Google-Smtp-Source: APXvYqxCd8Py6VXEISa/a96zqi5LxkqKrOSGPQkkIZmaZhVcgaYgP9KUSsHX0jc/5zmsuehKqrJxNldN/sloIoX09Wk= X-Received: by 2002:ac2:4c9c:: with SMTP id d28mr7059083lfl.119.1567791720030; Fri, 06 Sep 2019 10:42:00 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Bart Schaefer Date: Fri, 6 Sep 2019 10:41:48 -0700 Message-ID: Subject: Re: The best way to know it is in zsh or bash To: Peng Yu Cc: zsh-users Content-Type: text/plain; charset="UTF-8" On Fri, Sep 6, 2019 at 7:42 AM Peng Yu 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. Where/when is it that you want to do this? The two shells have an entirely distinct set of startup files (except that many packaged distributions have /etc/zshrc loading /etc/bashrc or similar) so I take it that it's sometime after that? > I see ZSH_* > environment variables. Is ZSH_VERSION the most appropriate to be used > to test whether it is in zsh or not? The ZSH_* variables are normally global shell parameters, not exported to the environment. If something is exporting them, it probably should not be. ZSH_VERSION is the oldest of these (if you are worried about differences within zsh itself), so it should be OK to examine. See Mikael's answer.