From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29659 invoked by alias); 15 Sep 2016 18:03:04 -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: X-Seq: 21916 Received: (qmail 1162 invoked from network); 15 Sep 2016 18:03:04 -0000 X-Qmail-Scanner-Diagnostics: from out2-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.26):SA:0(0.0/5.0):. Processed in 0.360465 secs); 15 Sep 2016 18:03:04 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_PASS,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: vq@larryv.me X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at spf.messagingengine.com designates 66.111.4.26 as permitted sender) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=larryv.me; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=qCThDhsaiPbTrgoEV5SM1IRHLm4=; b=Hk3HYu OJW5stkB6naF0KfS71b8pe3uzD/VEdt9hw6XvGO/zzwTmc4K44WyqDohCCcQ8UVI K8pTt6CxXANjsTK/fpLmax47yOXFn846GsHIq8o8dtZbf1qNQ/6/6IMBSnACovKJ JqOKaGRIOAxNI+2KGWHB4XPMaEWBOxjT4EKVQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=qCThDhsaiPbTrgo EV5SM1IRHLm4=; b=I0KOXNmv0+XaSJUC86KF+L7+O0cpWqBUbyYgajMG05DRs0Z jhz9fbvtsvXgM389h7zt0qlfqd2Ki0bTKfhHBlioZA6XSAiNMlkvi77gpthn4Fjg vlQ734BB7/rpC7rWzdZMtZ8MRO3P4Xu9TVydBNhSILgDvum6hjaGrBusb4D8= X-Sasl-enc: Wovd0UZG33bc5atNfOrDRENqUb5iLz/jvfAjCtcUaGuF 1473962062 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Subject: Re: How to detect that Zsh startup is result of exec zsh? From: =?utf-8?Q?Lawrence_Vel=C3=A1zquez?= In-Reply-To: Date: Thu, 15 Sep 2016 13:54:22 -0400 Cc: zsh-users@zsh.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <20160913140643.56f99ccf@pwslap01u.europe.root.pri> <20160913143042.3907c2b3@pwslap01u.europe.root.pri> To: Sebastian Gniazdowski X-Mailer: Apple Mail (2.3124) > On Sep 15, 2016, at 2:31 AM, Sebastian Gniazdowski = wrote: >=20 > On 13 September 2016 at 15:30, Peter Stephenson > wrote: >> BTW, telling you're in a subshell when you're still in the parent = shell >> is actually easy: >>=20 >> zmodload zsh/system >> if (( $$ =3D=3D $sysparams[pid] )); then >> print "I'm in the parent shell" >> else >> print "I'm in a subshell" >> fi >>=20 >> However, that's too early for you --- you need to know at the start = of >> the new zsh. I think some external mapping to PIDs is the only = reliable >> way. >>=20 >> pws >=20 > For me the two values are always the same: > https://asciinema.org/a/1tpk0k6jii36iwrzawlr2ador >=20 > This reminds me $ZSH_SUBSHELL that Mikael proposed, which is always 0 = for me: > https://asciinema.org/a/1jtfup4jrl14w7bps84wupqai >=20 > Testing this on IRC bot gave correct result, i.e. "1" was assigned > after running zsh IIRC. So maybe this is OS X issue, maybe even the > same in both cases? You're not actually using any subshells. % zsh --version zsh 5.2 (x86_64-apple-darwin15.6.0) % typeset ZSH_SUBSHELL ZSH_SUBSHELL=3D0 % (typeset ZSH_SUBSHELL) ZSH_SUBSHELL=3D1 % ( (typeset ZSH_SUBSHELL) ) ZSH_SUBSHELL=3D2 % zmodload zsh/system % (( $$ =3D=3D $sysparams[pid] )); echo $? 0 % ( (( $$ =3D=3D $sysparams[pid] )); echo $?) 1 vq=