Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: How to detect that Zsh startup is result of exec zsh?
- X-seq: zsh-users 21916
- From: Lawrence Velázquez <vq@xxxxxxxxx>
- To: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- Subject: Re: How to detect that Zsh startup is result of exec zsh?
- Date: Thu, 15 Sep 2016 13:54:22 -0400
- Cc: zsh-users@xxxxxxx
- 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=
- In-reply-to: <CAKc7PVB6+QcQXe2x1+UeADpZpsNcN1=a48cfR=c4OVp23pJXwg@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>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CGME20160913122504eucas1p121867b112b7f08e125a324230d8296df@eucas1p1.samsung.com> <CAKc7PVCErL0ZykRG-72foh8URN1UsO9jvPHuxiCDkum_pooXYg@mail.gmail.com> <20160913140643.56f99ccf@pwslap01u.europe.root.pri> <CAKc7PVAGqeJK=kdpQ9hSBcgpJmn639X94BU0CoNR2m6L2VBfcg@mail.gmail.com> <20160913143042.3907c2b3@pwslap01u.europe.root.pri> <CAKc7PVB6+QcQXe2x1+UeADpZpsNcN1=a48cfR=c4OVp23pJXwg@mail.gmail.com>
> On Sep 15, 2016, at 2:31 AM, Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx> wrote:
>
> On 13 September 2016 at 15:30, Peter Stephenson
> <p.stephenson@xxxxxxxxxxx> wrote:
>> BTW, telling you're in a subshell when you're still in the parent shell
>> is actually easy:
>>
>> zmodload zsh/system
>> if (( $$ == $sysparams[pid] )); then
>> print "I'm in the parent shell"
>> else
>> print "I'm in a subshell"
>> fi
>>
>> 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.
>>
>> pws
>
> For me the two values are always the same:
> https://asciinema.org/a/1tpk0k6jii36iwrzawlr2ador
>
> This reminds me $ZSH_SUBSHELL that Mikael proposed, which is always 0 for me:
> https://asciinema.org/a/1jtfup4jrl14w7bps84wupqai
>
> 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=0
% (typeset ZSH_SUBSHELL)
ZSH_SUBSHELL=1
% ( (typeset ZSH_SUBSHELL) )
ZSH_SUBSHELL=2
% zmodload zsh/system
% (( $$ == $sysparams[pid] )); echo $?
0
% ( (( $$ == $sysparams[pid] )); echo $?)
1
vq
Messages sorted by:
Reverse Date,
Date,
Thread,
Author