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:06, Peter Stephenson
<p.stephenson@xxxxxxxxxxx> wrote:
> On Tue, 13 Sep 2016 14:23:23 +0200
> Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx> 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 – person opening new
pane gets new Zsh, with new ID. But the exec case could still inherit
ID – replacing Zsh inside Tmux is fine to inherit ID. That's why I
need to differentiate the two

Best regards,
Sebastian Gniazdowski



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