Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: How to detect that Zsh startup is result of exec zsh?

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:

This reminds me $ZSH_SUBSHELL that Mikael proposed, which is always 0 for me:

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

Messages sorted by: Reverse Date, Date, Thread, Author