zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: $PPID not updated when the PPID changes (parent killed)
Date: Tue, 18 May 2021 17:14:54 +0100 (BST)	[thread overview]
Message-ID: <2130274784.211534.1621354494808@mail2.virginmedia.com> (raw)
In-Reply-To: <CAHYJk3Q0PRJG9pinJ2WG+n1Jjokd_WzfcjCRzYsY+SNNyghi-A@mail.gmail.com>

On 18 May 2021 at 16:18 Mikael Magnusson <mikachu@gmail.com> wrote:
> On 5/18/21, Bart Schaefer <schaefer@brasslantern.com> wrote:
> > Aside, it's a bit odd that SHLVL isn't read-only.  Even assorted Bash
> > tutorials found by online search treat it as immutable (statements
> > like "$dog is only available at SHLVL 2") despite that it can be
> > arbitrarily messed with.
> 
> I sometimes set it (in practice only to the empty string), such that
> the first shell in a new terminal always ends up with SHLVL=1 (my
> prompt hilights when it is non-1 so that i know i can safely exit
> without having the terminal be closed, eg while testing new zsh builds
> or other things where i want a temporary shell state). I also do some
> window manager development so things like "SHLVL= openbox --replace"
> tend to happen as well.

I do similar stuff to the extent of resetting SHLVL to zero, but I think
there is actually a logical argument for being able to adjust it, i.e.
set it rather than reset it, if you happen to know that's going to have a
useful effect.

For example, if SHLVL=1 before a terminal emulator starts because there's
a shell that spawned the window initialisation (this used to be a lot
more common way back when), then it's 2 in your terminal.  It would
be quite natural to start a new terminal (actually forked from the
current one, but logically at the same level as far as the user is
concerned) prefixed with:

SHLVL=$(( SHLVL - 1 ))

Then your init files in the new terminal behave as they do in the
one you're in.

I'm certainly not saying this is the absolute one true way of doing
things, only that I don't think it should be excluded.  It's fairly
low level; I think it's a case of giving enough rope etc.  I don't
think we have any expectation of or guidance on what people do with this
anyway.

pws


  reply	other threads:[~2021-05-18 16:15 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-16 15:24 Vincent Lefevre
2021-05-16 18:37 ` Bart Schaefer
2021-05-17 20:26   ` Vincent Lefevre
2021-05-17 21:00     ` Bart Schaefer
2021-05-17 22:27       ` Phil Pennock
2021-05-17 23:15         ` Bart Schaefer
2021-05-18  0:30           ` Phil Pennock
2021-05-18  1:14             ` Bart Schaefer
2021-05-18  8:28             ` Vincent Lefevre
2021-05-18  8:15           ` Vincent Lefevre
2021-05-18 14:53             ` Bart Schaefer
2021-05-19  4:25               ` Bart Schaefer
2021-07-18 23:10                 ` Lawrence Velázquez
2021-05-18 15:18           ` Mikael Magnusson
2021-05-18 16:14             ` Peter Stephenson [this message]
2021-05-18 18:20               ` Bart Schaefer
2021-05-18 17:37           ` Martijn Dekker
2021-05-18 18:08             ` Bart Schaefer
2021-05-18 19:40               ` Martijn Dekker
2021-05-18 18:06           ` Stephane Chazelas
2021-05-18 18:12             ` Bart Schaefer
2021-05-18 18:50               ` $SHLVL origin (was: $PPID not updated when the PPID changes (parent killed)) Stephane Chazelas
2021-05-18 15:56         ` $PPID not updated when the PPID changes (parent killed) Stephane Chazelas

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=2130274784.211534.1621354494808@mail2.virginmedia.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@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).