Subject: [bug] $SHLVL decremented for the last command of a subshell
From: Stephane Chazelas <[email-masked]>
To: Zsh hackers list <[email-masked]>
Date: Mon, 22 Aug 2016 07:17:23 +0100
List-Id: Zsh Workers List <zsh-workers.zsh.org>

(from https://unix.stackexchange.com/questions/304917/detect-when-zsh-is-running-within-the-subshell-of-another-shell)

$ printenv SHLVL
1
$ (printenv SHLVL)
0
$ (printenv SHLVL;:)
1
$ (:;printenv SHLVL)
0

http://www.zsh.org/mla/workers/1999/msg02472.html
sounds like a potential culprit.

-- 
Stephane