zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: [RFC][PATCH] Add zrestart()
Date: Sun, 9 May 2021 15:52:01 -0700	[thread overview]
Message-ID: <CAH+w=7Yzgiotj0iXv-jqvvc=F==P0BWKwOtofN-_dFt9bfUuew@mail.gmail.com> (raw)
In-Reply-To: <38b40e63-68f5-4cee-ada9-e665d1ce9927@www.fastmail.com>

On Sun, May 9, 2021 at 2:00 PM Lawrence Velázquez <larryv@zsh.org> wrote:
>
> Anything else on this?

There's really no ideal solution for this.  The only "good" way to
handle it is to have two different windows/terminals/whatever from
which to log in, so you can leave the old shell running while you test
whether a fresh login works properly.

Given we can't assure that, a scheme that occurs to me, but might be
tricky to make work smoothly:

At the beginning of $HOME/.zshenv, check for existence of a
$HOME/.zsh-safe file (exact name TBD).
If that file exists, set ZDOTDIR to something
innocuous/nonexistent/freshly-created, and print a message telling the
user he needs to repair his startup files and try again.  Sleep for a
few seconds and then return from .zshenv.
If the file does not exist, create it, and print a message advising
the user that if a shell prompt is reached, to remove the file and
also remove the test code from $HOME/.zshenv.  Sleep for a few seconds
and then go on with whatever else is in ~/.zshenv.

It's then safe to use "exec zsh" (or "exec zsh -l" if the shell is
already a login shell) because even if the user is kicked all the way
out of his remote session, he'll be able to log back in under the
"safe mode" created in ~/.zshenv and try again.

zrestart should thus unset ZDOTDIR, insert the test code into
~/.zshenv, and remove the .zsh-safe file.

Various details that might also be considered:

When creating the file, set up a precmd hook that cleans up the above
and unhooks itself, so the user doesn't have to do anything.  This
could be clobbered by later code, though, so printing the instructions
is probably still useful.

Do some or all of this only if .zshenv is run from an interactive shell.

There's no way to prevent /etc/zshenv from foiling all of this, e.g.,
by setting ZDOTDIR.


      reply	other threads:[~2021-05-09 22:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-24 20:50 Marlon Richert
2021-04-26  3:22 ` Daniel Shahaf
2021-04-26 19:03   ` Marlon Richert
2021-04-26 19:29     ` Daniel Shahaf
2021-04-26 23:54       ` Bart Schaefer
2021-04-27 11:42         ` Marlon Richert
2021-04-27 11:49           ` Roman Perepelitsa
2021-04-27 17:49             ` Marlon Richert
2021-04-27 17:57               ` Marlon Richert
2021-04-27 18:37                 ` Bart Schaefer
2021-04-29 13:58           ` Daniel Shahaf
2021-04-27 11:37       ` Marlon Richert
2021-04-29 14:12         ` Daniel Shahaf
2021-04-30 17:27           ` Marlon Richert
2021-05-09 20:59             ` Lawrence Velázquez
2021-05-09 22:52               ` Bart Schaefer [this message]

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='CAH+w=7Yzgiotj0iXv-jqvvc=F==P0BWKwOtofN-_dFt9bfUuew@mail.gmail.com' \
    --to=schaefer@brasslantern.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).