From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12669 invoked by alias); 14 Sep 2016 00:15:25 -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: 21897 Received: (qmail 29241 invoked from network); 14 Sep 2016 00:15:25 -0000 X-Qmail-Scanner-Diagnostics: from mail-qk0-f172.google.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(209.85.220.172):SA:0(1.1/5.0):. Processed in 0.311161 secs); 14 Sep 2016 00:15:25 -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=1.1 required=5.0 tests=DATE_IN_PAST_06_12, FREEMAIL_FROM,SPF_PASS,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.1 X-Envelope-From: sgniazdowski@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.220.172 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=Vv3TcjgVfFjZxaJ68gur8H1t7KjisU6hCF/oWrJ1Q/4=; b=YBf3L7KpZEYbNbZjdWl5Uv6emv6e+y0iRDHYaCAKpxKvlLkIrigidrZc+/F1RT+fR5 eflVoRNHldqNpYDlg/4Uf5zLUDtcVGXj+4tat6rwaeTgEggS7+nIAuljFDWPjfaVyNh1 Yi6f/N2fkSba9Ue3ZvTIc2Bu2kZwtotDmSTBCrNPAE4B/2ham6G7RfEvVfafNwd2AZM8 R7cIl/1t1RFyWO4nDbeqgZnJgOKPbCe9a9B2yStFLw1eXud8T+oAqHqQ/qJZQAlo01lW 5BKFx5KMPV8fc2Da5OgTubqHqUf+1x6zo7qOhDMyWeeSaTTzlgsibXaou768T1zu/XNh pjmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=Vv3TcjgVfFjZxaJ68gur8H1t7KjisU6hCF/oWrJ1Q/4=; b=CM7ybkHaV8i7YtRiYBSbq/2lNbTVtT/TRL52ZOr5V9KwqdLIEJohWAeWRkeFmgZ7Nr XmdRbMO8GOgt6bVTGBxFHgjKwAEMzUQ2+uvGzkb0Z83FTtM1s2i+BeeLBvKGyEJcext0 xwQ0s0ukurYAAH3UcVUu4ueMPlUTu6VGN6Lh/wibKdLWV663hAqHqcOdu07o2A0Ttvba 9YsGfAEKzp7HTkmCN6Ri8xL2lUaa1BOJQeEaBMCvxa1x5I1d1/39cuimmR8XZFWKSrkO +9jw3QcbgftIKiB7lcd1DddQRPSdzgzvDA1N4m9XBJI6hlylUO/AeqvB8zNk83KBo/F6 hvBw== X-Gm-Message-State: AE9vXwNB/n0jZm6MWafA+o/N/lCUNODkAnVlOHoVmG5PwxYVNhHZKg9Sa+6kjTE3FFcXV/T10NxOnCHoexz2Mw== X-Received: by 10.55.169.193 with SMTP id s184mr868143qke.3.1473772763837; Tue, 13 Sep 2016 06:19:23 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20160913140643.56f99ccf@pwslap01u.europe.root.pri> References: <20160913140643.56f99ccf@pwslap01u.europe.root.pri> From: Sebastian Gniazdowski Date: Tue, 13 Sep 2016 15:19:03 +0200 Message-ID: Subject: Re: How to detect that Zsh startup is result of exec zsh? To: Peter Stephenson Cc: Zsh Users Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 13 September 2016 at 15:06, Peter Stephenson wrote: > On Tue, 13 Sep 2016 14:23:23 +0200 > Sebastian Gniazdowski wrote: >> Hello, >> first `exec zsh` can be detected via SHLVL. It will be "1". And some >> other variable set in .zshrc earlier will be non-zero. But what with >> `exec zsh` ran from sub-shell? > > More widely, in fact, because fork and exec are so basic to UNIX-like > process handling it's often not possible, and usually not useful, to > tell this sort of thing apart. > > So the real question, as so often, is what you are actually trying to > do? What makes it necessary that you treat the cases differently? If > you can address that there may be an answer. I'm assigning unique ID to every Zsh. If one runs Zsh in side Zsh, either by exec or by new Zsh, the ID is inherited. However, there's Tmux. There, ID is not inherited in both cases =E2=80=93 person opening new pane gets new Zsh, with new ID. But the exec case could still inherit ID =E2=80=93 replacing Zsh inside Tmux is fine to inherit ID. That's why I need to differentiate the two Best regards, Sebastian Gniazdowski