zsh-users
 help / color / mirror / code / Atom feed
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Peter Stephenson <p.stephenson@samsung.com>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: How to detect that Zsh startup is result of exec zsh?
Date: Thu, 15 Sep 2016 08:31:03 +0200	[thread overview]
Message-ID: <CAKc7PVB6+QcQXe2x1+UeADpZpsNcN1=a48cfR=c4OVp23pJXwg@mail.gmail.com> (raw)
In-Reply-To: <20160913143042.3907c2b3@pwslap01u.europe.root.pri>

On 13 September 2016 at 15:30, Peter Stephenson
<p.stephenson@samsung.com> 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?

Best regards,
Sebastian Gniazdowski


  reply	other threads:[~2016-09-15  8:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20160913122504eucas1p121867b112b7f08e125a324230d8296df@eucas1p1.samsung.com>
2016-09-13 12:23 ` Sebastian Gniazdowski
2016-09-13 13:06   ` Peter Stephenson
2016-09-13 13:19     ` Sebastian Gniazdowski
2016-09-13 13:30       ` Peter Stephenson
2016-09-15  6:31         ` Sebastian Gniazdowski [this message]
2016-09-15 17:54           ` Lawrence Velázquez
2016-09-15 18:02             ` Sebastian Gniazdowski

Reply instructions:

You may reply publicly 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='CAKc7PVB6+QcQXe2x1+UeADpZpsNcN1=a48cfR=c4OVp23pJXwg@mail.gmail.com' \
    --to=sgniazdowski@gmail.com \
    --cc=p.stephenson@samsung.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).